Skip to content

Commit

Permalink
test: Adding tests for LDContextBuilder (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
ActuallyConnor authored Oct 7, 2024
1 parent 0adc270 commit 5b25095
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/LDContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ public function testBuilderSetBuiltInAttributeByNameTypeChecking()
self::assertFalse($b->trySet('anonymous', null));
self::assertFalse($b->trySet('anonymous', 3));
self::assertTrue($b->build()->isAnonymous());

$b->set('custom-attribute', null);
$b->set('custom-attribute', 3);
self::assertTrue($b->trySet('custom-attribute', null));
self::assertTrue($b->trySet('custom-attribute', 3));
self::assertEquals(['custom-attribute'], $b->build()->getCustomAttributeNames());
}

public function testGetBuiltInAttributeByName()
Expand Down Expand Up @@ -172,6 +178,17 @@ public function testPrivateAttributes()
);
}

public function testPrivateEmptyAttributes()
{
self::assertNull(LDContext::create('a')->getPrivateAttributes());

$c = LDContext::builder('a')->private()->build();
self::assertEquals(
null,
$c->getPrivateAttributes()
);
}

public function testCreateMulti()
{
$c1 = LDContext::create('a', 'kind1');
Expand Down

0 comments on commit 5b25095

Please sign in to comment.