-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: update test frameworks and restore unit tests in CI
Behat dependencies have been updated, but it is not expected that the tests will work.
- Loading branch information
Showing
7 changed files
with
166 additions
and
157 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
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 |
---|---|---|
@@ -1,25 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false"> | ||
<testsuites> | ||
<testsuite name="unit"> | ||
<directory suffix=".php">tests/Unit</directory> | ||
</testsuite> | ||
<testsuite name="integration"> | ||
<directory suffix=".php">tests/Integration</directory> | ||
</testsuite> | ||
</testsuites> | ||
<listeners> | ||
<listener class="TestListener" file="tests/TestListener.php"/> | ||
</listeners> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/9.2/phpunit.xsd" | ||
backupGlobals="false" | ||
bootstrap="./vendor/autoload.php" | ||
colors="true" | ||
beStrictAboutTestsThatDoNotTestAnything="true" | ||
beStrictAboutOutputDuringTests="true" | ||
convertErrorsToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertDeprecationsToExceptions="true"> | ||
<testsuites> | ||
<testsuite name="unit"> | ||
<directory suffix=".php">tests/Unit</directory> | ||
<exclude>tests/Unit/AntispamBeeTest.php</exclude> | ||
</testsuite> | ||
<testsuite name="integration"> | ||
<directory suffix=".php">tests/Integration</directory> | ||
</testsuite> | ||
</testsuites> | ||
<listeners> | ||
<listener class="TestListener" file="tests/TestListener.php"/> | ||
</listeners> | ||
</phpunit> |
This file was deleted.
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 |
---|---|---|
|
@@ -3,12 +3,16 @@ | |
namespace AntispamBee\Tests\Unit\Core; | ||
|
||
use Antispam_Bee as Testee; | ||
use AntispamBee\Tests\TestCase; | ||
use Brain\Monkey\Functions; | ||
use Yoast\WPTestUtils\BrainMonkey\TestCase; | ||
|
||
use function Brain\Monkey\Functions\expect; | ||
use function Brain\Monkey\Functions\when; | ||
|
||
/** | ||
* Test case for the factory class. | ||
* | ||
* TODO: This is a legacy test from 2.x. Update or remove. | ||
* | ||
* @since 2.7.0 | ||
*/ | ||
class FactoryTest extends TestCase { | ||
|
@@ -18,20 +22,20 @@ class FactoryTest extends TestCase { | |
* | ||
* @since 2.7.0 | ||
*/ | ||
protected function setUp() { | ||
parent::setUp(); | ||
protected function set_up() { | ||
parent::set_up(); | ||
|
||
Functions::when( 'get_bloginfo' )->justReturn( 'https://domain.com/' ); | ||
Functions::when( 'wp_parse_url' )->alias('parse_url'); | ||
Functions::when( 'is_admin' )->justReturn( false ); | ||
Functions::expect( 'wp_unslash' ) | ||
when( 'get_bloginfo' )->justReturn( 'https://domain.com/' ); | ||
when( 'wp_parse_url' )->alias('parse_url'); | ||
when( 'is_admin' )->justReturn( false ); | ||
expect( 'wp_unslash' ) | ||
->andReturnUsing( | ||
function( $data ) { | ||
return $data; | ||
} | ||
); | ||
|
||
Functions::when( 'get_option' )->justReturn( $this->get_options() ); | ||
when( 'get_option' )->justReturn( $this->get_options() ); | ||
|
||
Testee::init(); | ||
} | ||
|
@@ -81,18 +85,16 @@ public function test_gets_ip_address() { | |
* | ||
* @covers Testee::handle_incoming_request() | ||
* | ||
* @param array $comment Comment overrides to use. | ||
* @param string $reason Expected spam reason to catch. | ||
*/ | ||
public function test_spam_reasons( $comment, $reason ) { | ||
$comment = array_merge( $this->get_base_comment(), $comment ); | ||
public function test_spam_reasons($comment, $reason) { | ||
$comment = array_merge($this->get_base_comment(), $comment); | ||
|
||
$_SERVER['HTTP_CLIENT_IP'] = '12.23.34.45'; | ||
$_SERVER['REQUEST_URI'] = 'https://domain.com/wp-comments-post.php'; | ||
$_POST['comment'] = $comment; | ||
|
||
// This is where we check for the spam reason that was detected. | ||
Functions::expect( 'add_comment_meta' )->once() | ||
expect( 'add_comment_meta' )->once() | ||
->with( | ||
1, | ||
'antispam_bee_reason', | ||
|
@@ -133,7 +135,7 @@ public function spam_reasons_data_provider() { | |
// @ToDo: static $_reason | ||
array( | ||
array( | ||
'comment_content' => "this is a pharmacy, why does it work now?.", | ||
'comment_content' => "this is a pharmacy, why does it work now?.", | ||
'comment_author_email' => '[email protected]', | ||
), | ||
'regexp', | ||
|
Oops, something went wrong.