Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
--TEST--
2
File_Sitemap: Add and remove url from sitemap index.
3
--FILE--
4
<?php
5
require_once "File/Sitemap/Index.php";
6
 
7
try {
8
$sm = new File_Sitemap_Index();
9
 
10
$sm->add("http://mysite.net/sitemap1.gz");
11
$sm->add("http://mysite.net/sitemap2.gz");
12
$sm->add("http://mysite.net/sitemap3.gz");
13
$sm->remove("http://mysite.net/sitemap2.gz");
14
 
15
$filename = tempnam("/tmp", "sitemapindex").".xml";
16
 
17
$sm->save($filename, false, true);
18
 
19
$f = fopen($filename, 'r');
20
if ($f === false) {
21
	throw new Exception("Cannot open file");
22
}
23
while (!feof($f)) {
24
	echo fread($f, 10000);
25
}
26
fclose($f);
27
unlink($filename);
28
}
29
catch (Exception $e) {
30
	echo $e->getMessage();
31
}
32
 
33
?>
34
--EXPECT--
35
<?xml version="1.0" encoding="UTF-8"?>
36
<sitemapindex 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/siteindex.xsd">
37
  <sitemap>
38
    <loc>http://mysite.net/sitemap1.gz</loc>
39
  </sitemap>
40
  <sitemap>
41
    <loc>http://mysite.net/sitemap3.gz</loc>
42
  </sitemap>
43
</sitemapindex>