Exemple #1
0
 public function testShouldSeedSiteGenerator()
 {
     $faker = Faker::create();
     $host = $faker->url;
     $generator = new Generator();
     $generator->setHostname($host);
     $generator->setOutputDir(__DIR__);
     $total = rand(1, 100);
     $seeder = new FakerSeeder();
     $seeder->setTotal($total);
     $seeder->seed($generator);
     $this->assertEquals($total, $generator->getCurrentSitemap()->count());
 }
Exemple #2
0
<?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();
 public function testShouldNotify()
 {
     $generator = new Generator();
     $generator->setOutputDir($this->outputDir);
     $generator->setHostname('http://www.example.com');
     $generator->setCompress(true);
     $generator->addUrl(new Url('/'));
     $generator->addUrl(new Url('/path1'));
     $generator->addUrl(new Url('/path2', '2014-01-01'));
     $notifier = $this->getMock('\\Sitemapper\\EngineNotifier', array('notify'));
     $notifier->expects($this->once())->method('notify')->with($generator->getLocation());
     $generator->addNotifier($notifier);
     $generator->generate();
 }