diff --git a/package.json b/package.json index de1fe518..838198a2 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,8 @@ "backstop:test": "npm exec backstop test", "lighthouse": "lighthouse-ci http://localhost:8888/ --accessibility=100 --best-practices=100 --seo=100", "lighthouse:desktop": "lighthouse http://localhost:8888/ --view --preset=desktop --output-path=lighthouse.html", - "lighthouse:mobile": "lighthouse http://localhost:8888/ --view --screenEmulation.mobile --output-path=lighthouse.html" + "lighthouse:mobile": "lighthouse http://localhost:8888/ --view --screenEmulation.mobile --output-path=lighthouse.html", + "test": "./vendor/phpunit/phpunit/phpunit tests/phpunit" }, "workspaces": [ "source/wp-content/themes/wporg-main-2022" diff --git a/tests/phpunit/smokeTest.php b/tests/phpunit/smokeTest.php new file mode 100644 index 00000000..02ed1b90 --- /dev/null +++ b/tests/phpunit/smokeTest.php @@ -0,0 +1,84 @@ +curl_body = curl_exec( $ch ); + $this->curl_error = curl_error( $ch ) ?: null; + + curl_close( $ch ); + + return $this->curl_body; + } + + public function urls() { + return array( + ['http://localhost:8888/'], + ['http://localhost:8888/download/'], + ); + } + + /** + * @dataProvider urls + */ + public function testHasBodyTag( $url ): void + { + $this->fetch_url( $url ); + + $this->assertStringContainsString( 'curl_body ); + $this->assertStringContainsString( '', $this->curl_body ); + } + + /** + * @dataProvider urls + */ + public function testClosingHtml( $url ): void + { + $this->fetch_url( $url ); + + $this->assertStringEndsWith( '', rtrim( $this->curl_body ) ); + } + + /** + * @dataProvider urls + */ + public function testHasTitle( $url ): void + { + $this->fetch_url( $url ); + + $this->assertRegExp( '#[^<>]+ WordPress.org#', $this->curl_body ); + } + + /** + * @dataProvider urls + */ + public function testHasMetaDescription( $url ): void + { + $this->fetch_url( $url ); + + $this->assertRegExp( '#]+" />#', $this->curl_body ); + $this->assertRegExp( '#]+" />#', $this->curl_body ); + } + + /** + * @dataProvider urls + */ + public function testHasHrefLang( $url ): void + { + $this->markTestSkipped( 'Requires https://github.com/WordPress/wporg-main-2022/pull/54' ); + $this->fetch_url( $url ); + + $this->assertRegExp( '##', $this->curl_body ); + } + +}