public function testPatternSetAndMatch() { $object = new Rule(); $object->disallow('/section*'); $this->assertFalse($object->match('/section/tout/cetuqiadjoa.jpg')); $object->allow('/toto*.php$'); $this->assertTrue($object->match('/toto/tata.PHP')); $this->assertTrue($object->match('/toto/tata.php')); $object->allow('/truite'); $this->assertTrue($object->match('/truite/et/tout/cetuqiadjoa.jpg')); $object->disallow('/'); $this->assertFalse($object->match('/to/tata.php')); }
public function testMultipleExpression() { $this->given($sut = new SUT(''), $sut->disallow('/foo/bar'), $sut->allow('/foo/bar/baz$'), $sut->allow('/foo$'))->when($match = $sut->match('/foo/bar'))->then->boolean($match)->isFalse()->when($match = $sut->match('/foo/bar/baz/'))->then->boolean($match)->isFalse()->when($match = $sut->match('/foo/bar/baz'))->then->boolean($match)->isTrue(); }
public function testAddRule() { $this->given($sut = new SUT(), $ua = 'Google-Bot', $rule = new LUT\Rule($ua), $rule->allow('/url'), $rule->disallow('/private'))->when($sut->add($rule), $get = $sut->get($ua))->then->integer(count($sut))->isEqualTo(2)->object($get)->isInstanceOf('Bee4\\RobotsTxt\\Rule')->isEqualTo($rule)->boolean($sut->match($ua, '/url'))->isTrue()->boolean($sut->match($ua, '/private'))->isFalse(); }