Skip to content

Commit 5b25095

Browse files
test: Adding tests for LDContextBuilder (#209)
1 parent 0adc270 commit 5b25095

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Diff for: tests/LDContextTest.php

+17
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ public function testBuilderSetBuiltInAttributeByNameTypeChecking()
140140
self::assertFalse($b->trySet('anonymous', null));
141141
self::assertFalse($b->trySet('anonymous', 3));
142142
self::assertTrue($b->build()->isAnonymous());
143+
144+
$b->set('custom-attribute', null);
145+
$b->set('custom-attribute', 3);
146+
self::assertTrue($b->trySet('custom-attribute', null));
147+
self::assertTrue($b->trySet('custom-attribute', 3));
148+
self::assertEquals(['custom-attribute'], $b->build()->getCustomAttributeNames());
143149
}
144150

145151
public function testGetBuiltInAttributeByName()
@@ -172,6 +178,17 @@ public function testPrivateAttributes()
172178
);
173179
}
174180

181+
public function testPrivateEmptyAttributes()
182+
{
183+
self::assertNull(LDContext::create('a')->getPrivateAttributes());
184+
185+
$c = LDContext::builder('a')->private()->build();
186+
self::assertEquals(
187+
null,
188+
$c->getPrivateAttributes()
189+
);
190+
}
191+
175192
public function testCreateMulti()
176193
{
177194
$c1 = LDContext::create('a', 'kind1');

0 commit comments

Comments
 (0)