Skip to content

TestData update generates error when updating a changed flag #160

Closed
@aretenz

Description

@aretenz

According to the docs, TestData update can be used more than once on the same flag if its definition has been changed. Specifically this paragraph:

Any subsequent changes to this FlagBuilder instance do not affect the test data, unless you call update(FlagBuilder) again.

However when it is called again on the same flag, an error is generated:

Error: Cannot use object of type LaunchDarkly\Impl\Model\FeatureFlag as array

I believe that is caused by line 133 in TestData.php:

$oldVersion = $oldFlag['version'];

The effect is that TestData does not update itself with the changed flag and still operates with the previous definition

If that line is changed as follows then the error no longer occurs:

$oldVersion = $oldFlag->getVersion();

To test I used a simplified variation of testCanSetAndGetFeatureFlag in TestDataTest.php that proceeds to change the flag definition and then update it again.

At this stage I would need to install multiple versions of php for thorough testing. I have only tested it while running php 8.1.

The work around is:

  • when updating a flag for a second time on the same TestData instance
  • then create a new TestData and LDClient and update on the new TestData.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions