-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Allow creation of assignment event from array
- Loading branch information
Showing
2 changed files
with
107 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace AmplitudeExperiment\Test\Amplitude; | ||
|
||
use AmplitudeExperiment\Amplitude\Event; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class EventTest extends TestCase | ||
{ | ||
public function testToAndFromArray(): void | ||
{ | ||
$event = new Event( | ||
'eventType', | ||
['eventProperty' => 'eventValue'], | ||
['userProperty' => 'userValue'], | ||
'userId', | ||
'deviceId', | ||
'insertId', | ||
1234567890 | ||
); | ||
|
||
$this->assertEquals( | ||
[ | ||
'event_type' => 'eventType', | ||
'event_properties' => ['eventProperty' => 'eventValue'], | ||
'user_properties' => ['userProperty' => 'userValue'], | ||
'user_id' => 'userId', | ||
'device_id' => 'deviceId', | ||
'insert_id' => 'insertId', | ||
'time' => 1234567890 | ||
], | ||
$event->toArray() | ||
); | ||
|
||
$this->assertEquals( | ||
$event, | ||
Event::fromArray($event->toArray()) | ||
); | ||
} | ||
} |