-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add configuration for running tests
Thanks to the work done in roots/bedrock#366 .
- Loading branch information
Showing
7 changed files
with
87 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,5 +38,10 @@ | |
"scripts": { | ||
"lint": "phpcs", | ||
"test": "phpunit" | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Tests\\": "tests/src" | ||
} | ||
} | ||
} |
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,20 @@ | ||
<?xml version="1.0"?> | ||
<phpunit | ||
bootstrap="tests/bootstrap.php" | ||
backupGlobals="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
> | ||
<testsuites> | ||
<testsuite name="unit"> | ||
<directory suffix="Test.php">./tests/unit/</directory> | ||
<exclude>./tests/test-sample.php</exclude> | ||
</testsuite> | ||
</testsuites> | ||
<php> | ||
<env name="WP_ENV" value="testing"/> | ||
<env name="WP_PHPUNIT__TABLE_PREFIX" value="tests_"/> | ||
</php> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
/** | ||
* PHPUnit bootstrap file | ||
* | ||
* Composer autoloader must be loaded before WP_PHPUNIT__DIR will be available. | ||
*/ | ||
|
||
require_once(dirname(__DIR__) . '/vendor/autoload.php'); | ||
|
||
// Give access to tests_add_filter() function. | ||
require_once(getenv('WP_PHPUNIT__DIR') . '/includes/functions.php'); | ||
|
||
tests_add_filter('muplugins_loaded', function () { | ||
// test set up, plugin activation, etc. | ||
}); | ||
|
||
// Start up the WP testing environment. | ||
putenv(sprintf('WP_PHPUNIT__TESTS_CONFIG=%s/wp-config.php', __DIR__)); | ||
require(getenv('WP_PHPUNIT__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,11 @@ | ||
<?php | ||
|
||
namespace Tests; | ||
|
||
class TestCase extends \WP_UnitTestCase | ||
{ | ||
/** | ||
* Here you can define your own custom assertions or helper methods | ||
* which will be available to all your tests that extend it. | ||
*/ | ||
} |
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,12 @@ | ||
<?php | ||
|
||
namespace Tests; | ||
|
||
class ExampleTest extends TestCase | ||
{ | ||
/** @test */ | ||
function it_works() | ||
{ | ||
$this->assertTrue(function_exists('add_action')); | ||
} | ||
} |
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,7 @@ | ||
<?php | ||
/** | ||
* Do not edit this file. Edit the config files found in the config/ dir instead. | ||
* Test-specific configuration is found in config/environments/testing.php. | ||
*/ | ||
require_once(dirname(__DIR__) . '/vendor/autoload.php'); | ||
require_once(dirname(__DIR__) . '/bedrock/config/application.php'); |