Skip to content

Commit ff5512f

Browse files
committed
Convert robots double slash test to PHPUnit
1 parent 7b194f7 commit ff5512f

2 files changed

Lines changed: 38 additions & 18 deletions

File tree

integration-tests/test/wp2static_test/detect_test.clj

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,3 @@ Sitemap: http://localhost:7000/does-not-exist.xml")
3030
"wp2static" "detect"))))
3131
(finally
3232
(test/sh! {} "rm" "wordpress/robots.txt" "wordpress/wp-content/sitemap.xml"))))))
33-
34-
(def robots-sitemap-slashes
35-
"User-agent: *
36-
Disallow: /wp-admin/
37-
Allow: /wp-admin/admin-ajax.php
38-
39-
Sitemap: http://localhost:7000//wp-sitemap.xml")
40-
41-
(deftest test-robots-sitemap-slashes
42-
(testing "robots.txt sitemap URLs with double slashes are processed"
43-
(test/with-test-system [_]
44-
(try
45-
(spit "wordpress/robots.txt" robots-sitemap-slashes)
46-
(test/wp-cli! {} "wp2static" "detect")
47-
(test/wp-cli! {} "wp2static" "crawl")
48-
(is (str/includes? (get-crawled-file "wp-sitemap-posts-post-1.xml") "http://localhost:7000/hello-world/"))
49-
(finally
50-
(test/sh! {} "rm" "wordpress/robots.txt"))))))

tests/integration/DetectTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace WP2Static;
4+
5+
use PHPUnit\Framework\TestCase;
6+
7+
final class DetectTest extends TestCase {
8+
9+
use ITTrait;
10+
11+
public function testSitemapDoubleSlashes(): void
12+
{
13+
$robotstxt = ITEnv::getWordPressDir() . '/robots.txt';
14+
$robotstxt_content = 'User-agent: *
15+
Disallow: /wp-admin/
16+
Allow: /wp-admin/admin-ajax.php
17+
18+
Sitemap: http://localhost:8888//wp-sitemap.xml';
19+
file_put_contents( $robotstxt, $robotstxt_content );
20+
21+
$this->wpCli( [ 'wp2static', 'detect' ] );
22+
$this->wpCli( [ 'wp2static', 'crawl' ] );
23+
24+
$content = $this->getCrawledFileContents( 'robots.txt' );
25+
$this->assertStringContainsString(
26+
'http://localhost:8888//wp-sitemap.xml',
27+
$content
28+
);
29+
30+
$content = $this->getCrawledFileContents( 'wp-sitemap-posts-post-1.xml' );
31+
$this->assertStringContainsString(
32+
'http://localhost:8888/hello-world/',
33+
$content
34+
);
35+
36+
exec( 'rm -f ' . escapeshellarg( $robotstxt ) );
37+
}
38+
}

0 commit comments

Comments
 (0)