Skip to content

Commit

Permalink
add Assignment to json payload test
Browse files Browse the repository at this point in the history
  • Loading branch information
tyiuhc committed Feb 13, 2024
1 parent d6af1cc commit 807cb38
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/Assignment/AssignmentServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
use AmplitudeExperiment\Assignment\AssignmentFilter;
use AmplitudeExperiment\Assignment\AssignmentService;
use AmplitudeExperiment\Assignment\DefaultAssignmentTrackingProvider;
use AmplitudeExperiment\Logger\DefaultLogger;
use AmplitudeExperiment\Logger\InternalLogger;
use AmplitudeExperiment\Logger\LogLevel;
use AmplitudeExperiment\User;
use AmplitudeExperiment\Variant;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -50,7 +47,7 @@ public function testAssignmentToEventAsExpected()
'empty_variant' => new Variant()
];

$assignment = new Assignment($user, $results);
$assignment = new Assignment($user, $results, 'apiKey', 10);
$event = $assignment->toEvent();

$this->assertEquals($user->userId, $event->userId);
Expand Down Expand Up @@ -84,6 +81,9 @@ public function testAssignmentToEventAsExpected()
$canonicalization = 'user device basic control default off different_value on empty_metadata on holdout holdout mutex slot-1 partial_metadata on ';
$expected = "user device " . hashCode($canonicalization) . ' ' . floor($assignment->timestamp / DAY_MILLIS);
$this->assertEquals($expected, $event->insertId);
$expectedPayload = json_encode(["api_key" => 'apiKey', "events" => [$event], "options" => ["min_id_length" => 10]]);
$this->assertEquals($expectedPayload, $assignment->toJSONPayload());
echo $assignment->toJSONPayload() . "\n";
}

public function testlogEventCalledInAmplitude()
Expand Down

0 comments on commit 807cb38

Please sign in to comment.