<?php
/**
 * This file is part of the beebot package.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @copyright Bee4 2015
 * @author    Stephane HULARD <s.hulard@chstudio.fr>
 * @package   Test\Bee4\RobotsTxt
 */

namespace Test\Bee4\RobotsTxt;

use Bee4\RobotsTxt\Parser;

/**
 * Parser unit test
 * @package Test\Bee4\RobotsTxt
 */
class ParserTest extends \PHPUnit_Framework_TestCase
{
	protected $content = "User-agent: *
Disallow: /mentions-legales/

User-agent: google-bot
Allow: /truite.php
disallow: /";

	public function testParse() {
		$object = new Parser($this->content);
		$rules = $object->parse();

		$rule = $rules->get('*');
		$this->assertInstanceOf('\Bee4\RobotsTxt\Rule', $rule);

		$this->assertFalse($rule->match('/mentions-legales/'));
		$this->assertTrue($rule->match('/another-page.html'));

		$this->assertFalse($rules->match('Google-Bot v01', '/toto'));
		$this->assertTrue($rules->match('Google-Bot v01', '/truite.php'));
	}
}

Add tests on Parser + Rules
Add tests on Parser + Rules

Signed-off-by: Stéphane HULARD <a24f38cb8c57ec2778c80a9f0c151933508927e5@chstudio.fr>
