This commit is contained in:
2022-11-25 21:21:30 +01:00
parent 2d6df0d5f0
commit 94deb06f52
132 changed files with 44887 additions and 41368 deletions

View File

@@ -1,4 +1,5 @@
<?php
/** DomFramework - Tests
* @package domframework
* @author Dominique Fournier <dominique@fournier38.fr>
@@ -14,46 +15,52 @@ use Domframework\Sitemap;
class SitemapTest extends \PHPUnit_Framework_TestCase
{
// Empty Sitemap
public function test_EmptySitemap_1 ()
{
$sitemap = new Sitemap ();
$res = $sitemap->analyze ("", "http://example.com");
$this->assertSame ($res, ["urls" => [], "sitemaps" => []]);
}
public function test_EmptySitemap_1()
{
$sitemap = new Sitemap();
$res = $sitemap->analyze("", "http://example.com");
$this->assertSame($res, ["urls" => [], "sitemaps" => []]);
}
// Empty Sitemap
public function test_EmptySitemap_2 ()
{
$sitemap = new Sitemap ();
$res = $sitemap->analyze (" ", "http://example.com");
$this->assertSame ($res, ["urls" => [], "sitemaps" => []]);
}
public function test_EmptySitemap_2()
{
$sitemap = new Sitemap();
$res = $sitemap->analyze(" ", "http://example.com");
$this->assertSame($res, ["urls" => [], "sitemaps" => []]);
}
// Textual Sitemap
public function test_TextualSitemap_1 ()
{
$sitemap = new Sitemap ();
$res = $sitemap->analyze ("http://example.com", "http://example.com");
$this->assertSame ($res,
["urls" => ["http://example.com" => []],
"sitemaps" => []]);
}
public function test_TextualSitemap_2 ()
{
$sitemap = new Sitemap ();
$res = $sitemap->analyze ("http://example.com\nhttps://www.example.com\n\n",
"http://example.com");
$this->assertSame ($res,
["urls" => ["http://example.com" => [], "https://www.example.com" => []],
"sitemaps" => []]);
}
public function test_TextualSitemap_1()
{
$sitemap = new Sitemap();
$res = $sitemap->analyze("http://example.com", "http://example.com");
$this->assertSame(
$res,
["urls" => ["http://example.com" => []],
"sitemaps" => []]
);
}
public function test_TextualSitemap_2()
{
$sitemap = new Sitemap();
$res = $sitemap->analyze(
"http://example.com\nhttps://www.example.com\n\n",
"http://example.com"
);
$this->assertSame(
$res,
["urls" => ["http://example.com" => [], "https://www.example.com" => []],
"sitemaps" => []]
);
}
// XML Sitemap
public function test_XMLSitemap_1 ()
{
$sitemap = new Sitemap ();
$res = $sitemap->analyze (
'<?xml version="1.0" encoding="utf-8"?>
public function test_XMLSitemap_1()
{
$sitemap = new Sitemap();
$res = $sitemap->analyze(
'<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
@@ -64,21 +71,24 @@ class SitemapTest extends \PHPUnit_Framework_TestCase
<priority>0.8</priority>
</url>
</urlset>',
"http://example.com");
$this->assertSame ($res,
["urls" => [
"http://example.com/" => ["changefreq" => "daily",
"http://example.com"
);
$this->assertSame(
$res,
["urls" => [
"http://example.com/" => ["changefreq" => "daily",
"priority" => 0.8,
"lastmod" => 1163808000]
],
"sitemaps" => []]);
}
],
"sitemaps" => []]
);
}
public function test_XMLSitemap_2 ()
{
$sitemap = new Sitemap ();
$res = $sitemap->analyze (
'<?xml version="1.0" encoding="utf-8"?>
public function test_XMLSitemap_2()
{
$sitemap = new Sitemap();
$res = $sitemap->analyze(
'<?xml version="1.0" encoding="utf-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>http://www.example.com/sitemap1.xml.gz</loc>
@@ -89,14 +99,17 @@ class SitemapTest extends \PHPUnit_Framework_TestCase
<lastmod>2005-01-01</lastmod>
</sitemap>
</sitemapindex>',
"http://example.com");
$this->assertSame ($res,
["urls" => [],
"sitemaps" => [
"http://www.example.com/sitemap1.xml.gz" => [
"lastmod" => 1096654997,],
"http://www.example.com/sitemap2.xml.gz" => [
"lastmod" => 1104537600, ],
]]);
}
"http://example.com"
);
$this->assertSame(
$res,
["urls" => [],
"sitemaps" => [
"http://www.example.com/sitemap1.xml.gz" => [
"lastmod" => 1096654997,],
"http://www.example.com/sitemap2.xml.gz" => [
"lastmod" => 1104537600, ],
]]
);
}
}