Closed bopoda closed 7 years ago
You can do Test like this
<?php
class SitemapsTest extends \PHPUnit_Framework_TestCase
{
public static function setUpBeforeClass()
{
require_once(realpath(__DIR__.'/../RobotsTxtParser.php'));
}
/**
* @dataProvider generateDataForTest
*/
public function testRemoveComments($robotsTxtContent)
{
$parser = new RobotsTxtParser($robotsTxtContent);
$this->assertInstanceOf('RobotsTxtParser', $parser);
// Check if the number of sitemaps is 1
$this->assertTrue(count($parser->getSitemaps()) == 1);
}
/**
* Generate test case data
*
* @return array
*/
public function generateDataForTest()
{
return array(
array("
Sitemap: http://example.com/sitemap.xml?year=2017
Sitemap: http://example.com/sitemap.xml?year=2017
Sitemap: http://example.com/sitemap.xml?year=2017
")
);
}
}
ok, i will add this test soon. It should work as expected now because array_unique called in prepareRules before.
@LeMoussel, test added in commit https://github.com/bopoda/robots-txt-parser/commit/c03c6567ec80c8b7ef21a499fe622c230529d02d, test passed.
Resolve https://github.com/bopoda/robots-txt-parser/issues/7