/** * @testdox Default rules * @dataProvider getDefault */ public function testDefault($tags, $expected) { $rulesGenerator = new RulesGenerator(); $tagCollection = new TagCollection(); foreach ($tags as $tagName => $template) { $tag = $tagCollection->add($tagName); if (isset($template)) { $tag->template = $template; } } $this->assertEquals($expected, $rulesGenerator->getRules($tagCollection)); }
/** * @testdox Bitfields are compressed by making tags that are targeted by the same permissions share the same bit number */ public function testTwoIdenticalTags() { $tags = new TagCollection(); $tags->add('A'); $tags->add('B'); $this->assertEquals(['root' => ['allowed' => [0b100000001]], 'tags' => ['A' => ['bitNumber' => 0, 'allowed' => [0b100000001]], 'B' => ['bitNumber' => 0, 'allowed' => [0b100000001]]]], RulesHelper::getBitfields($tags, new Ruleset())); }
/** * @testdox Throws an exception when accessing a Tag that does not exist * @expectedException RuntimeException * @expectedExceptionMessage Tag 'X' does not exist */ public function testNotExist() { $collection = new TagCollection(); $collection->get('X'); }