-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BWP-96] Add support for running integration tests
Using the WP-PHPUnit framework we can run integration tests with WP - this test suite will spin up a working version of WP and run the tests.
- Loading branch information
Showing
9 changed files
with
193 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<phpunit | ||
bootstrap="tests/phpintegration-bootstrap.php" | ||
backupGlobals="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
beStrictAboutTestsThatDoNotTestAnything="true" | ||
beStrictAboutOutputDuringTests="true" | ||
> | ||
<php> | ||
<env name="WP_PHPUNIT__TESTS_CONFIG" value="tests/phpintegration-wp-config.php" /> | ||
</php> | ||
<testsuites> | ||
<testsuite name="Integration Tests"> | ||
<directory suffix=".php">tests/integration</directory> | ||
</testsuite> | ||
</testsuites> | ||
<coverage> | ||
<include> | ||
<directory suffix=".php">./wp-content/mu-plugins</directory> | ||
<directory suffix=".php">./wp-content/themes</directory> | ||
</include> | ||
<exclude> | ||
<directory suffix=".php">./wp-content/mu-plugins/vendor</directory> | ||
</exclude> | ||
</coverage> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
/** | ||
* Sample Test | ||
* | ||
* @package BoxUk | ||
*/ | ||
|
||
declare( strict_types=1 ); | ||
|
||
namespace BoxUk\Tests\Integration; | ||
|
||
use WP_UnitTestCase; | ||
|
||
/** | ||
* Sample test case. | ||
*/ | ||
class SampleTest extends WP_UnitTestCase { | ||
|
||
public function test_sample() { | ||
$this->assertTrue( true ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
/** | ||
* Bootstrap the WordPress tests. | ||
*/ | ||
|
||
declare ( strict_types=1 ); | ||
|
||
$root = dirname( __DIR__ ); | ||
$composer = json_decode( file_get_contents( $root . '/composer.json' ), true, 512, JSON_THROW_ON_ERROR ); | ||
$vendor = $composer['config']['vendor-dir']; | ||
$tests_dir = getenv( 'WP_PHPUNIT__DIR' ); | ||
|
||
require_once $vendor . '/autoload.php'; | ||
require_once $tests_dir . '/includes/functions.php'; | ||
require_once $tests_dir . '/includes/bootstrap.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare ( strict_types=1 ); | ||
|
||
use Symfony\Component\Dotenv\Dotenv; | ||
|
||
$root = dirname( __DIR__ ); | ||
$composer = json_decode( file_get_contents( $root . '/composer.json' ), true, 512, JSON_THROW_ON_ERROR ); | ||
$vendor = $composer['config']['vendor-dir']; | ||
|
||
require_once $vendor . '/autoload.php'; | ||
|
||
if ( is_readable( $root . '/.env' ) ) { | ||
$dotenv = new Dotenv(); | ||
$dotenv->usePutenv( true ); | ||
$dotenv->load( $root . '/.env' ); | ||
} | ||
|
||
/* DB */ | ||
define( 'DB_NAME', $_ENV['DB_NAME'] ?? 'wordpress' ); | ||
define( 'DB_USER', $_ENV['DB_USER'] ?? 'root' ); | ||
define( 'DB_PASSWORD', $_ENV['DB_PASSWORD'] ?? 'root' ); | ||
define( 'DB_COLLATE', $_ENV['DB_COLLATE'] ?? 'utf8mb4_unicode_ci' ); | ||
define( 'DB_HOST', $_ENV['DB_HOST'] ?? '127.0.0.1' ); | ||
$table_prefix = 'wptests_'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited | ||
|
||
/* WP */ | ||
define( 'WP_DEBUG', true ); | ||
define( 'SCRIPT_DEBUG', true ); | ||
define( 'ABSPATH', $root . '/wp/' ); | ||
define( 'WP_CONTENT_DIR', $root . '/wp-content' ); | ||
define( 'WP_DEFAULT_THEME', 'default' ); | ||
define( 'WP_ENVIRONMENT_TYPE', 'development' ); | ||
define( 'WP_TESTS_DOMAIN', 'tests.boxuk.com' ); | ||
define( 'WP_TESTS_EMAIL', '[email protected]' ); | ||
define( 'WP_TESTS_TITLE', 'Test Blog' ); | ||
define( 'WP_PHP_BINARY', 'php' ); | ||
define( 'PROJECT_NAME', 'boxuk' ); | ||
|
||
if (file_exists($root . '/wp-content/vip-config/vip-config.php')) { | ||
require_once($root . '/wp-content/vip-config/vip-config.php'); | ||
} |