Skip to content

Conversation

@oakbani
Copy link
Contributor

@oakbani oakbani commented Nov 15, 2017

Contains changes of #71

Covered Unit Tests

Notification Listener

  • addListener Invalid params (invalid type, invalid callable) ✔️
  • addListener Verify added
    • anaonymous function ✔️
    • object function ✔️
    • plain function ✔️
  • addNotificationForMultipleNotificationTypes ✔️
  • addNotificationForMultipleCallbacksForSingleNotificationType ✔️
  • addListener Verify already added is not re-added ✔️
  • removeListener
    • Verify nothing is removed if id not found ✔️
    • Verify removed ✔️
    • Verify nothing is removed for the same id(for which a callback was removed) ✔️
  • clearListener
    • Invalid ID ✔️
    • Verify all removed for ID and remaining intact ✔️
  • clearAllListeners Verify all removed ✔️
  • fireNotification
    • Exception case. Less num of args given than expected ✔️
    • Verify all callables with args are executed and no other types are called ✔️
    • Verify all callables without args are executed and no other types are called ✔️

Optimizely
Note: Separate sendImpression unit testing from activate unit tests and verify that activate calls/not calls send impression given scenario

  • sendImpression

    • Verify calls fireNotification without attributes ✔️
    • Verify calls fireNotification with attributes ✔️
  • track Verify calls fireNotification where relevant ✔️

  • isFeatureEnabled calls fireNotification both with source Experiment and source Rollout ✔️

@optibot
Copy link

optibot commented Nov 15, 2017

Can one of the admins verify this patch?

@coveralls
Copy link

coveralls commented Nov 15, 2017

Coverage Status

Coverage increased (+1.05%) to 94.195% when pulling 42a285a on msohailhussain:Feature-NotificationCenter into afa7a55 on optimizely:master.

@coveralls
Copy link

coveralls commented Nov 16, 2017

Coverage Status

Coverage increased (+1.09%) to 94.234% when pulling bd218fc on msohailhussain:Feature-NotificationCenter into afa7a55 on optimizely:master.

* @param array $args Array of items to pass as arguments to the callback
*
*/
public function fireNotifications($notification_type, array $args = [])

Choose a reason for hiding this comment

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

can we change this to sendNotifications?

$featureFlagKey,
$userId,
$attributes,
$audience

Choose a reason for hiding this comment

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

we are passing back an array of audiences. it should be the audience that the user fit. right now it will be an array of one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. I am confused on why are we always picking the first audience. Please see my comment here
https://github.com/optimizely/python-sdk/pull/88/files/8d4c3b2476fc7e5e4f1dc8504fb7068e8065a327#diff-2340ceb056ad364022b798c358a6c8ffR399

$this->_logger->log(Logger::ERROR, sprintf(
'Unable to dispatch conversion event. Error %s', $exception->getMessage()));
}

Choose a reason for hiding this comment

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

I like the sendImpression. Why not add a sendConversion as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sendImpression logic got separated from activate when we implemented isFeatureEnabled that had to send an impression event as well. Track is the only method right now that sends a conversion event. Separating out unit tests for sendConversion will require a lot of changes. Shall I do it in this PR or can we do it later?

Choose a reason for hiding this comment

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

We can do it later if necessary.

@coveralls
Copy link

Coverage Status

Coverage increased (+1.03%) to 94.175% when pulling 898242f on msohailhussain:Feature-NotificationCenter into afa7a55 on optimizely:master.

@coveralls
Copy link

coveralls commented Nov 17, 2017

Coverage Status

Coverage increased (+1.09%) to 94.234% when pulling 898242f on msohailhussain:Feature-NotificationCenter into afa7a55 on optimizely:master.

…-NotificationCenter

# Conflicts:
#	src/Optimizely/Optimizely.php
#	src/Optimizely/ProjectConfig.php
#	tests/OptimizelyTest.php
#	tests/UtilsTests/VariableTypeUtilsTest.php
@coveralls
Copy link

coveralls commented Nov 21, 2017

Coverage Status

Coverage decreased (-0.4%) to 94.234% when pulling ab37eb7 on msohailhussain:Feature-NotificationCenter into d0c5f4e on optimizely:master.

@coveralls
Copy link

coveralls commented Nov 21, 2017

Coverage Status

Coverage decreased (-0.2%) to 94.453% when pulling e8863d6 on msohailhussain:Feature-NotificationCenter into d0c5f4e on optimizely:master.

@coveralls
Copy link

coveralls commented Nov 22, 2017

Coverage Status

Coverage decreased (-0.3%) to 94.328% when pulling a18700d on msohailhussain:Feature-NotificationCenter into d0c5f4e on optimizely:master.

Copy link

@thomaszurkan-optimizely thomaszurkan-optimizely left a comment

Choose a reason for hiding this comment

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

I didn't see where you were testing that all the correct type arguments are passed for ACTIVATE, and TRACK callbacks. Did I miss something?

class NotificationType
{
// format is EVENT: list of parameters to callback.
const ACTIVATE = "ACTIVATE:experiment, user_id,attributes, variation, event";

Choose a reason for hiding this comment

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

add space after attributes

$this->_logger->log(Logger::ERROR, sprintf(
'Unable to dispatch conversion event. Error %s', $exception->getMessage()));
}

Choose a reason for hiding this comment

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

We can do it later if necessary.

@oakbani
Copy link
Contributor Author

oakbani commented Nov 27, 2017

@thomaszurkan-optimizely
For activate, I verify that sendImpression is called with expected params such as here: https://github.com/optimizely/php-sdk/pull/73/files#diff-d1e79f065af60553c7d6afdd00433a85R394
I have added similar in each activate unit test both when sendImpression is expected and when it's not.

The unit tests for sendImpression verify that it's fireNotifications is called with expected params for ACTIVATE

For Track, I verify that fireNotifications is called with expected params. Such as here
https://github.com/optimizely/php-sdk/pull/73/files#diff-d1e79f065af60553c7d6afdd00433a85R1567
and similarly in other TRACK unit tests

@coveralls
Copy link

coveralls commented Nov 27, 2017

Coverage Status

Coverage decreased (-0.3%) to 94.328% when pulling c0a1ada on msohailhussain:Feature-NotificationCenter into d0c5f4e on optimizely:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 94.328% when pulling 146a886 on msohailhussain:Feature-NotificationCenter into d4a4aad on optimizely:master.

1 similar comment
@coveralls
Copy link

coveralls commented Nov 27, 2017

Coverage Status

Coverage decreased (-0.3%) to 94.328% when pulling 146a886 on msohailhussain:Feature-NotificationCenter into d4a4aad on optimizely:master.

@coveralls
Copy link

coveralls commented Nov 29, 2017

Coverage Status

Coverage increased (+2.2%) to 96.844% when pulling a2e8bee on msohailhussain:Feature-NotificationCenter into d4a4aad on optimizely:master.

}

$variationId = $experimentToVariationMap[$experimentId];
// check for null and empty string variation ID
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We already enforce these checks in setForcedVariation


$variation = $this->getVariationFromId($experimentKey, $variationId);
$variationKey = $variation->getKey();
// check if the variation exists in the datafile (a new variation is returned if it is not in the datafile)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above

@mikeproeng37
Copy link
Contributor

E2E tests are passing. Merging in.

@mikeproeng37 mikeproeng37 merged commit 4cb2c35 into optimizely:master Nov 29, 2017
@oakbani oakbani deleted the Feature-NotificationCenter branch November 30, 2017 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants