Skip to content

Commit

Permalink
[TASK] Use MockWebServer in tests
Browse files Browse the repository at this point in the history
The MockWebServer provides the possibility to test
individual scenarios like robots.txt and gzipped files.

Closes #14
Closes #15
  • Loading branch information
schliesser committed May 14, 2024
1 parent 5702686 commit c3db983
Show file tree
Hide file tree
Showing 9 changed files with 328 additions and 149 deletions.
395 changes: 253 additions & 142 deletions Tests/Functional/Command/CrawlSitemapCommandTest.php

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Tests/Functional/Fixtures/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
User-agent: *
Allow: /

Sitemap: http://127.0.0.1:1337/sitemap-1.xml
Sitemap: http://127.0.0.1:1337/sitemap-2.xml
Sitemap: http://127.0.0.1:1337/sitemap-index-1.xml
Sitemap: http://127.0.0.1:1337/sitemap-index-2.xml
10 changes: 10 additions & 0 deletions Tests/Functional/Fixtures/sitemap-1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="/typo3/sysext/seo/Resources/Public/CSS/Sitemap.xsl"?>

<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

<url>
<loc>http://127.0.0.1:1337/</loc>
<lastmod>2020-06-12T11:49:26+02:00</lastmod>
</url>

</urlset>
15 changes: 15 additions & 0 deletions Tests/Functional/Fixtures/sitemap-2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="/typo3/sysext/seo/Resources/Public/CSS/Sitemap.xsl"?>

<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

<url>
<loc>http://127.0.0.1:1337/</loc>
<lastmod>2020-06-12T11:49:26+02:00</lastmod>
</url>

<url>
<loc>http://127.0.0.1:1337/page</loc>
<lastmod>2020-06-12T11:49:26+02:00</lastmod>
</url>

</urlset>
Binary file added Tests/Functional/Fixtures/sitemap-2.xml.gz
Binary file not shown.
10 changes: 10 additions & 0 deletions Tests/Functional/Fixtures/sitemap-index-1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="/typo3/sysext/seo/Resources/Public/CSS/Sitemap.xsl"?>

<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

<sitemap>
<loc>http://127.0.0.1:1337/sitemap-1.xml</loc>
<lastmod>2020-06-30T10:36:11+02:00</lastmod>
</sitemap>

</sitemapindex>
15 changes: 15 additions & 0 deletions Tests/Functional/Fixtures/sitemap-index-2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="/typo3/sysext/seo/Resources/Public/CSS/Sitemap.xsl"?>

<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

<sitemap>
<loc>http://127.0.0.1:1337/sitemap-1.xml</loc>
<lastmod>2020-06-30T10:36:11+02:00</lastmod>
</sitemap>

<sitemap>
<loc>http://127.0.0.1:1337/sitemap-2.xml</loc>
<lastmod>2019-09-04T14:54:32+02:00</lastmod>
</sitemap>

</sitemapindex>
10 changes: 10 additions & 0 deletions Tests/Functional/Fixtures/sitemap-index-gz.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="/typo3/sysext/seo/Resources/Public/CSS/Sitemap.xsl"?>

<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

<sitemap>
<loc>http://127.0.0.1:1337/sitemap-2.xml.gz</loc>
<lastmod>2020-06-30T10:36:11+02:00</lastmod>
</sitemap>

</sitemapindex>
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@
}
],
"require": {
"typo3/cms-core": "^12.4 || ^v13.0",
"php": "^8.1",
"ext-simplexml": "*",
"ext-zlib": "*",
"php": "^8.1"
"typo3/cms-core": "^12.4 || ^v13.0"
},
"require-dev": {
"donatj/mock-webserver": "^2.7",
"friendsofphp/php-cs-fixer": "^3.0",
"php-parallel-lint/php-parallel-lint": "^1.2",
"saschaegerer/phpstan-typo3": "dev-master",
"typo3/cms-composer-installers": "^5.0",
"typo3/testing-framework": "^8.0",
"saschaegerer/phpstan-typo3": "dev-master"
"typo3/testing-framework": "^8.0"
},
"autoload": {
"psr-4": {
Expand All @@ -38,9 +39,9 @@
"bin-dir": ".Build/bin",
"allow-plugins": {
"typo3/class-alias-loader": true,
"typo3/cms-composer-installers": true,
"sbuerk/typo3-cmscomposerinstallers-testingframework-bridge": true
}
"typo3/cms-composer-installers": true
},
"sort-packages": true
},
"scripts": {
"test": [
Expand Down

0 comments on commit c3db983

Please sign in to comment.