/** * @dataProvider provide */ public function testIntegration($content, array $rules) { $sut = LUT\Parser::parse($content); foreach ($rules as $rule) { $this->when($matched = $sut->match($rule['ua'], $rule['url']))->then->boolean($rule['mode'] === 'allow')->isEqualTo($matched); } }
public function testParse() { $robot = <<<ROBOTS User-Agent: * Allow: / User-Agent: Google Disallow: /toto #Sitemap Sitemap: http://localhost ROBOTS; $this->given($rules = SUT::parse($robot))->then->sizeOf($rules)->isEqualTo(2)->boolean($rules->match('*', '/page'))->isTrue()->boolean($rules->match('Google', '/page'))->isTrue()->boolean($rules->match('Google', '/toto/page'))->isFalse()->array($rules->getSitemaps())->hasSize(1)->contains('http://localhost'); }
/** * @expectedException Bee4\RobotsTxt\Exception\DuplicateRuleException */ public function testDuplicateRuleParse() { $object = new Parser($this->duplicateRuleContent); $object->parse(); }