parser = new RobotsTxtParser(fopen(__DIR__ . '/Fixtures/allow-spec.txt', 'r')); } public function tearDown(): void { $this->parser = null; } public function testForCrawlerZ() { $this->assertTrue($this->parser->isAllowed('/', 'crawlerZ')); $this->assertTrue($this->parser->isDisallowed('/forum', 'crawlerZ')); $this->assertTrue($this->parser->isDisallowed('/public', 'crawlerZ')); $this->assertFalse($this->parser->isDisallowed('/', 'crawlerZ')); $this->assertFalse($this->parser->isAllowed('/forum', 'crawlerZ')); $this->assertFalse($this->parser->isAllowed('/public', 'crawlerZ')); } public function testForDefaultUserAgent() { $this->assertTrue($this->parser->isAllowed('/')); $this->assertTrue($this->parser->isAllowed('/article')); $this->assertTrue($this->parser->isDisallowed('/temp')); $this->assertTrue($this->parser->isDisallowed('/Admin')); $this->assertTrue($this->parser->isDisallowed('/admin')); $this->assertTrue($this->parser->isDisallowed('/admin/cp/test/')); $this->assertFalse($this->parser->isDisallowed('/')); $this->assertFalse($this->parser->isDisallowed('/article')); $this->assertFalse($this->parser->isAllowed('/temp')); $this->assertFalse($this->parser->isDisallowed('/article')); } public function testForAgentV() { $this->assertTrue($this->parser->isDisallowed('/foo', 'agentV')); $this->assertTrue($this->parser->isAllowed('/bar', 'agentV')); $this->assertTrue($this->parser->isAllowed('/Foo', 'agentV')); } public function testForAgentW() { $this->assertTrue($this->parser->isDisallowed('/foo', 'agentW')); $this->assertTrue($this->parser->isAllowed('/bar', 'agentW')); $this->assertTrue($this->parser->isAllowed('/Foo', 'agentW')); } public function testForBotY() { $this->assertTrue($this->parser->isDisallowed('/', 'botY-test')); $this->assertTrue($this->parser->isDisallowed('/forum', 'botY-test')); $this->assertTrue($this->parser->isAllowed('/forum/', 'botY-test')); $this->assertTrue($this->parser->isDisallowed('/forum/topic', 'botY-test')); $this->assertTrue($this->parser->isDisallowed('/public', 'botY-test')); $this->assertFalse($this->parser->isAllowed('/', 'botY-test')); $this->assertFalse($this->parser->isAllowed('/forum', 'botY-test')); $this->assertFalse($this->parser->isDisallowed('/forum/', 'botY-test')); $this->assertFalse($this->parser->isAllowed('/forum/topic', 'botY-test')); $this->assertFalse($this->parser->isAllowed('/public', 'botY-test')); } /** * @param string $url * @param bool $isAllowed * * @dataProvider generateDataForSpiderX */ public function testForSpiderX(string $url, bool $isAllowed) { if ($isAllowed) { $this->assertTrue($this->parser->isAllowed($url, 'spiderX/1.0')); $this->assertFalse($this->parser->isDisallowed($url, 'spiderX/1.0')); } else { $this->assertTrue($this->parser->isDisallowed($url, 'spiderX/1.0')); $this->assertFalse($this->parser->isAllowed($url, 'spiderX/1.0')); } } public function generateDataForSpiderX(): array { return [ ['/temp', true], ['/assets', false], ['/forum', true], ]; } } __halt_compiler();----SIGNATURE:----yZ4VEEbg+fz+azTKQGVXwltEmNKnnffeOd9ncKEWzN0P/bvhvGXnhjZrbxiiA8JRrp68dVIj3fM8UnAf1XIPAODatpKhtdNsIxRiiU9IJrTAvCRp+BSTHvdDlm/1duoq93/YQ8jlct0rGrBKefHwMbIzm8FsKpTXFBts8y5tUK3ivw3c9KFu23mMmhOm6AXOOJqRlrIhniBJmv6przVyOOtYwbyMr5N15CkYYY5VOQp06WPoj5JxuS1wrJEtj9u9JpJCRKra6n2f9hf8VPUuFqAD0eKAMJKGHvG4ra1woYhKU3YOOxCKXwA+z433S9mBZlGENCPq63Zpi+K9Bz3aH0MO8+cAXBroWsX8KNu/8lgAb6MovdBd/ibLdtQTjr9CpNpbyWXzi+5culOISOu7ep5DZ2xmtP8caCE3MLIUak1fxqQmOlJOUAgWEvblO7t9xyT2k5eZGzQw5ZLZLEwQ/RkranEUeffpwul/7KSniDw+xMdNQXcQe69EGd1uXXXQfxmQy0OaeYtJLrSli6Pki4Kr/z7fDb6qfNbAcCE8txkymrNZuJ+3eFZl2MEUAufy2Kw+kx6uKGDYvouiqdNn28FG2DqVwBOToryFoMz+1Ox9RbScBlrHBFuaLomo1Syylrnu/9o5MP9D5zdv8ZkuVozSqvqoifqSH28Kfu0OjpE=----ATTACHMENT:----MzkxODM5NDQyMDA5NjYxMCAzNjEyODcwMTA0MDQ0Mzc1IDk1MTU3ODc5OTQ3MzAxNTI=