public function testShouldAddImage() { $image = new Image(new Image('http://www.example.com/image-path.jpg')); $url = new Url('http://www.example.com'); $url->addImage($image); $this->assertAttributeEquals(array($image), 'images', $url); $this->assertEquals(array($image), $url->getImages()); }
<?php require_once __DIR__ . '/../vendor/autoload.php'; date_default_timezone_set('America/Sao_Paulo'); use Sitemapper\Generator; use Sitemapper\Url; use Sitemapper\Image; use Faker\Factory; $faker = Factory::create(); $host = rtrim($faker->url, '/'); $generator = new \Sitemapper\Generator(); $generator->setOutputDir(sys_get_temp_dir()); $generator->setHostname($host); $generator->setOverwrite(true); $generator->setAutoSave(true); $generator->setMaxAllowedUrls(10000); $generator->setCompress(true); for ($i = 0; $i < 100000; $i++) { $loc = $host . '/' . $faker->uuid; echo $i . '=> ' . $loc . PHP_EOL; $randPriority = rand(Url::PRIORITY_LOW, Url::PRIORITY_HIGH); $url = new Url($loc, $faker->iso8601, Url::CHANGE_FREQUENCY_DAILY, $randPriority); // Adding images for ($j = 1; $j < $faker->randomDigit; $j++) { $url->addImage(new Image($loc, $faker->catchPhrase)); } $generator->addUrl($url); } $generator->generate();