Skip to content

feat: datafile accessor #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 28, 2020
Merged

Conversation

ozayr-zaviar
Copy link
Contributor

@ozayr-zaviar ozayr-zaviar commented Aug 25, 2020

Summary

  • toDatafile() method added in DatafileProjectConfig.
  • getDatafile() method added in OptimizelyConfig

Test plan

@aliabbasrizvi
Copy link
Contributor

@ozayr-zaviar can you take care of signing our CLA mentioned in the CONTRIBUTING document?

Copy link
Contributor

@oakbani oakbani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address.

@@ -159,4 +159,11 @@ public function getFeatureVariableFromKey($featureFlagKey, $variableKey);
* @return boolean A boolean value that indicates if the experiment is a feature test.
*/
public function isFeatureExperiment($experimentId);

/**
* Determines if given experiment is a feature test.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. Fix this docstring

@@ -63,6 +68,7 @@ public function __construct(ProjectConfigInterface $projectConfig)
$this->experiments = $projectConfig->getAllExperiments();
$this->featureFlags = $projectConfig->getFeatureFlags();
$this->revision = $projectConfig->getRevision();
$this->datafile = $$projectConfig->toDatafile();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit $$

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You haven't passed datafile to new OptimizelyConfig below

private $datafile;


public function __construct($revision, array $experimentsMap, array $featuresMap, $datafile = null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not provide a default null for datafile.

@@ -14,709 +14,464 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace Optimizely\Tests;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix this file. This should only show diff of the new unit test you have added.

public function testGetDatafile()
{
$expectedDatafile = DATAFILE_FOR_OPTIMIZELY_CONFIG;
$actualDatafile = $this->optConfigService->getDatafile();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getDatafile() has been defined for OptimizelyConfig, not OptimizelyConfigService.

@oakbani oakbani changed the title Datafile accessor feat: datafile accessor Aug 27, 2020
@oakbani
Copy link
Contributor

oakbani commented Aug 27, 2020

@msohailhussain Testapp PR should be merged to get FSC passed https://github.com/optimizely/php-testapp/pull/65

/**
* @var string datafile.
*/
private $datafile;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be $_datafile?

/**
* @var string Contents of datafile.
*/
private $datafile;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private $datafile;


public function __construct($revision, array $experimentsMap, array $featuresMap, $datafile)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't it break existing functionality?

@@ -31,7 +31,8 @@ public function testOptimizelyConfigEntity()
$optConfig = new OptimizelyConfig(
"20",
["a" => "apple"],
["o" => "orange"]
["o" => "orange"],
null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't be changed.

@@ -41,7 +42,8 @@ public function testOptimizelyConfigEntity()
$expectedJson = '{
"revision": "20",
"experimentsMap" : {"a": "apple"},
"featuresMap": {"o": "orange"}
"featuresMap": {"o": "orange"},
"datafile": null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.

Copy link
Contributor

@zashraf1985 zashraf1985 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Approving assuming my variable name suggestion will be incorporated before merge.

/**
* @var string datafile.
*/
private $datafile;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be $_datafile to be consistent with other private variable conventions. @oakbani ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the privacy convention has changed. I think @oakbani had showed me that previously. See: https://www.php-fig.org/psr/psr-12/#43-properties-and-constants

@@ -37,6 +37,11 @@ class OptimizelyConfigService
*/
private $revision;

/**
* @var string config datafile.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. @var string String denoting datafile.

Copy link
Contributor

@msohailhussain msohailhussain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mikeproeng37 mikeproeng37 merged commit a335f0f into optimizely:master Aug 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants