|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace vipnytt\SitemapParser\Tests; |
| 4 | + |
| 5 | +use PHPUnit\Framework\TestCase; |
| 6 | +use vipnytt\SitemapParser; |
| 7 | + |
| 8 | +class StripCommentsTest extends TestCase |
| 9 | +{ |
| 10 | + /** |
| 11 | + * @dataProvider generateDataForTest |
| 12 | + * @param string $url URL |
| 13 | + * @param string $body URL body content |
| 14 | + */ |
| 15 | + public function testStrict($url, $body) |
| 16 | + { |
| 17 | + $parser = new SitemapParser(); |
| 18 | + $this->assertInstanceOf('vipnytt\SitemapParser', $parser); |
| 19 | + $parser->parse($url, $body); |
| 20 | + $this->assertEquals([ |
| 21 | + 'https://www.bellinghambaymarathon.org/post-sitemap.xml' => [ |
| 22 | + 'loc' => 'https://www.bellinghambaymarathon.org/post-sitemap.xml', |
| 23 | + 'lastmod' => '2019-07-19T10:18:07-07:00' |
| 24 | + ], |
| 25 | + 'https://www.bellinghambaymarathon.org/page-sitemap.xml' => [ |
| 26 | + 'loc' => 'https://www.bellinghambaymarathon.org/page-sitemap.xml', |
| 27 | + 'lastmod' => '2019-07-29T06:51:35-07:00' |
| 28 | + ], |
| 29 | + 'https://www.bellinghambaymarathon.org/category-sitemap.xml' => [ |
| 30 | + 'loc' => 'https://www.bellinghambaymarathon.org/category-sitemap.xml', |
| 31 | + 'lastmod' => '2019-07-19T10:18:07-07:00' |
| 32 | + ], |
| 33 | + 'https://www.bellinghambaymarathon.org/post_tag-sitemap.xml' => [ |
| 34 | + 'loc' => 'https://www.bellinghambaymarathon.org/post_tag-sitemap.xml', |
| 35 | + 'lastmod' => '2019-05-16T10:06:14-07:00' |
| 36 | + ], |
| 37 | + 'https://www.bellinghambaymarathon.org/author-sitemap.xml' => [ |
| 38 | + 'loc' => 'https://www.bellinghambaymarathon.org/author-sitemap.xml', |
| 39 | + 'lastmod' => '2018-08-22T17:12:52-07:00' |
| 40 | + ], |
| 41 | + ], $parser->getSitemaps()); |
| 42 | + $this->assertEquals([], $parser->getURLs()); |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * Generate test data |
| 47 | + * @return array |
| 48 | + */ |
| 49 | + public function generateDataForTest() |
| 50 | + { |
| 51 | + return [ |
| 52 | + [ |
| 53 | + 'https://www.bellinghambaymarathon.org/sitemap_index.xml', |
| 54 | + <<<TEXT |
| 55 | +<!-- This page is cached by the Hummingbird Performance plugin v2.0.1 - https://wordpress.org/plugins/hummingbird-performance/. --> |
| 56 | +<?xml version="1.0" encoding="UTF-8"?> |
| 57 | + <?xml-stylesheet type="text/xsl" href="//www.bellinghambaymarathon.org/main-sitemap.xsl"?> |
| 58 | + <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> |
| 59 | + <sitemap> |
| 60 | + <loc>https://www.bellinghambaymarathon.org/post-sitemap.xml</loc> |
| 61 | + <lastmod>2019-07-19T10:18:07-07:00</lastmod> |
| 62 | + </sitemap> |
| 63 | + <sitemap> |
| 64 | + <loc>https://www.bellinghambaymarathon.org/page-sitemap.xml</loc> |
| 65 | + <lastmod>2019-07-29T06:51:35-07:00</lastmod> |
| 66 | + </sitemap> |
| 67 | + <sitemap> |
| 68 | + <loc>https://www.bellinghambaymarathon.org/category-sitemap.xml</loc> |
| 69 | + <lastmod>2019-07-19T10:18:07-07:00</lastmod> |
| 70 | + </sitemap> |
| 71 | + <sitemap> |
| 72 | + <loc>https://www.bellinghambaymarathon.org/post_tag-sitemap.xml</loc> |
| 73 | + <lastmod>2019-05-16T10:06:14-07:00</lastmod> |
| 74 | + </sitemap> |
| 75 | + <sitemap> |
| 76 | + <loc>https://www.bellinghambaymarathon.org/author-sitemap.xml</loc> |
| 77 | + <lastmod>2018-08-22T17:12:52-07:00</lastmod> |
| 78 | + </sitemap> |
| 79 | + </sitemapindex> |
| 80 | +<!-- XML Sitemap generated by Yoast SEO --><!-- Hummingbird cache file was created in 1.061126947403 seconds, on 01-08-19 23:06:50 --> |
| 81 | +TEXT |
| 82 | + ] |
| 83 | + ]; |
| 84 | + } |
| 85 | +} |
0 commit comments