2020-04-09 14:32:40 +00:00
|
|
|
<?php
|
2020-04-16 13:03:15 +00:00
|
|
|
/**
|
|
|
|
* CodeHackerTestHook class file.
|
|
|
|
*
|
2020-08-05 16:36:24 +00:00
|
|
|
* @package WooCommerce\Testing
|
2020-04-16 13:03:15 +00:00
|
|
|
*/
|
|
|
|
|
2020-05-18 09:31:59 +00:00
|
|
|
namespace Automattic\WooCommerce\Testing\Tools\CodeHacking;
|
2020-04-13 07:32:19 +00:00
|
|
|
|
2020-04-09 14:32:40 +00:00
|
|
|
use PHPUnit\Runner\BeforeTestHook;
|
|
|
|
|
|
|
|
/**
|
2020-06-02 08:08:24 +00:00
|
|
|
* Helper to use the CodeHacker class in PHPUnit. To use, add this to phpunit.xml:
|
2020-04-09 14:32:40 +00:00
|
|
|
*
|
|
|
|
* <extensions>
|
2020-04-13 07:32:19 +00:00
|
|
|
* <extension class="CodeHackerTestHook" />
|
2020-04-09 14:32:40 +00:00
|
|
|
* </extensions>
|
|
|
|
*/
|
2020-06-02 08:08:24 +00:00
|
|
|
final class CodeHackerTestHook implements BeforeTestHook {
|
2020-04-09 14:32:40 +00:00
|
|
|
|
2020-05-18 08:07:20 +00:00
|
|
|
/**
|
|
|
|
* Runs before each test.
|
|
|
|
*
|
|
|
|
* @param string $test "TestClass::TestMethod".
|
|
|
|
*
|
|
|
|
* @throws \ReflectionException Thrown by execute_before_methods.
|
|
|
|
*/
|
2020-04-09 14:32:40 +00:00
|
|
|
public function executeBeforeTest( string $test ): void {
|
2020-06-02 08:08:24 +00:00
|
|
|
CodeHacker::reset_hacks();
|
2020-04-09 14:32:40 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-16 13:03:15 +00:00
|
|
|
|