Skip to content

Commit 98c3888

Browse files
committed
WIP: wp-browser test suite
Current status: $ docker-compose run --rm codecept run functional Starting wordpress-core-web-vitals-lab_db_1 ... done Starting wordpress-core-web-vitals-lab_wordpress_1 ... done Starting wordpress-core-web-vitals-lab_upstream_1 ... done Starting wordpress-core-web-vitals-lab_varnish_1 ... done Starting wordpress-core-web-vitals-lab_server_1 ... done Starting wordpress-core-web-vitals-lab_testdb_1 ... done Codeception PHP Testing Framework v4.1.16 Powered by PHPUnit 9.5.1 by Sebastian Bergmann and contributors. Functional Tests (1) --------------------------------------------------------------------------------------- ✖ NewPageCest: Try to test (0.07s) ------------------------------------------------------------------------------------------------------------ Time: 00:01.419, Memory: 18.00 MB There was 1 failure: --------- 1) NewPageCest: Try to test Test tests/functional/NewPageCest.php:tryToTest Step See "Sign-up for our awesome thing" Fail Failed asserting that on page /signup/ --> Page not found – Core Web Vitals Lab img.wp-smiley, img.emoji { display: inline !important; border: none !important; box-shadow: none !important; height: 1em !important; width: 1em !important; margin: 0 .07em !important; vertical-align: -0.1em !important; background: none !important; padding: 0 !im [Content too long to display. See complete response in '/app/tests/_output/' directory] --> contains "Sign-up for our awesome thing". Scenario Steps: 3. $I->see("Sign-up for our awesome thing") at tests/functional/NewPageCest.php:19 2. $I->amOnPage("/signup/") at tests/functional/NewPageCest.php:18 1. $I->havePageInDatabase({"post_name":"signup","post_title":"Sign-up","post_content":"Sign-up for our...}) at tests/functional/NewPageCest.php:13 Artifacts: Html: /app/tests/_output/NewPageCest.tryToTest.fail.html Response: /app/tests/_output/NewPageCest.tryToTest.fail.html FAILURES! Tests: 1, Assertions: 1, Failures: 1. Next steps: - Isolate an installation to run the acceptance and functional tests - Move plugin unit tests to tests dir with the tests running with PHPUnit
1 parent 09d587b commit 98c3888

File tree

10 files changed

+457
-87
lines changed

10 files changed

+457
-87
lines changed

.env.testing

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ TEST_DB_HOST=testdb
1313
TEST_DB_USER=root
1414
TEST_DB_PASSWORD=db
1515
TEST_TABLE_PREFIX=wp_
16-
TEST_SITE_WP_URL=https://localhost
17-
TEST_SITE_WP_DOMAIN=localhost
16+
TEST_SITE_WP_URL=https://server
17+
TEST_SITE_WP_DOMAIN=server
1818
TEST_SITE_ADMIN_EMAIL=admin@localhost

docker-compose.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,13 @@ services:
9494
image: mariadb
9595
volumes:
9696
- testdb_data:/var/lib/mysql
97+
depends_on:
98+
- server
9799
environment:
98100
MYSQL_DATABASE: db
99101
MYSQL_ROOT_PASSWORD: db
102+
ports:
103+
- 3306:3306
100104

101105
plugin-cs:
102106
build:

docker/wp/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ COPY wp-install.sh /usr/local/bin/wp-install
4545
FROM base as tests
4646

4747
RUN set -ex; \
48-
\
48+
# Fix: iconv(): Wrong charset, conversion from `utf-8' to `us-ascii//TRANSLIT' is not allowed
49+
# Source: https://github.com/phpearth/docker-php/issues/3
50+
apk add --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing gnu-libiconv; \
4951
# Install tests PHP dependency
5052
docker-php-ext-install pdo_mysql
53+
54+
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php

tests/_data/dump.sql

Lines changed: 410 additions & 0 deletions
Large diffs are not rendered by default.

tests/_support/UnitTester.php

Lines changed: 0 additions & 26 deletions
This file was deleted.

tests/_support/WpunitTester.php

Lines changed: 0 additions & 26 deletions
This file was deleted.

tests/acceptance/HomePageCest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
class HomePageCest
4+
{
5+
public function _before(AcceptanceTester $I)
6+
{
7+
}
8+
9+
// tests
10+
public function tryToTest(AcceptanceTester $I)
11+
{
12+
$I->amOnPage('/');
13+
$I->see('Hello world!');
14+
}
15+
}

tests/functional/NewPageCest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
class NewPageCest
4+
{
5+
public function _before(FunctionalTester $I)
6+
{
7+
}
8+
9+
// tests
10+
public function tryToTest(FunctionalTester $I)
11+
{
12+
$I->havePageInDatabase( [
13+
'post_name' => 'signup',
14+
'post_title' => 'Sign-up',
15+
'post_content'=> 'Sign-up for our awesome thing! [signup]',
16+
] );
17+
18+
$I->amOnPage( '/signup/' );
19+
$I->see( 'Sign-up for our awesome thing' );
20+
}
21+
}

tests/unit.suite.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/wpunit.suite.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)