-
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.
WIP, still trying to find a good way of running tests locally and on …
…actions on a satisfactory way
- Loading branch information
1 parent
911fc50
commit ac4c3fb
Showing
9 changed files
with
25 additions
and
117 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
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,121 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
declare( strict_types=1 ); | ||
|
||
namespace Custom_PTT\Tests\Unit; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Custom_PTT\Plugin; | ||
use DI\Container; | ||
use Custom_PTT\Infrastructure\Registerable; | ||
use WP_Mock; | ||
use WP_UnitTestCase; | ||
|
||
/** | ||
* Class Plugin_Test | ||
* | ||
* @package Custom_PTT\Tests\Unit | ||
* @since 0.1.0-alpha | ||
*/ | ||
class Plugin_Test extends TestCase { | ||
class Plugin_Test extends WP_UnitTestCase { | ||
|
||
/** | ||
* Set up before the test class. | ||
* | ||
* @since 0.1.0-alpha | ||
*/ | ||
public static function setUpBeforeClass(): void { | ||
if ( ! defined( 'CUSTOM_PTT_FILE' ) ) { | ||
define( 'CUSTOM_PTT_FILE', 'custom-post-types-taxonomies/custom-post-types-taxonomies.php' ); | ||
} | ||
} | ||
|
||
/** | ||
* Set up the test. | ||
* | ||
* @since 0.1.0-alpha | ||
*/ | ||
protected function setUp(): void { | ||
WP_Mock::setUp(); | ||
} | ||
|
||
/** | ||
* Tear down the test. | ||
* | ||
* @since 0.1.0-alpha | ||
*/ | ||
protected function tearDown(): void { | ||
WP_Mock::tearDown(); | ||
} | ||
|
||
/** | ||
* Test register_hooks method. | ||
* | ||
* @since 0.1.0-alpha | ||
*/ | ||
public function test_register_hooks() { | ||
WP_Mock::userFunction( 'register_activation_hook' ); | ||
WP_Mock::userFunction( 'register_deactivation_hook' ); | ||
|
||
$container = $this->createMock( Container::class ); | ||
$plugin = new Plugin( $container ); | ||
|
||
$this->assertNull( $plugin->register_hooks() ); | ||
} | ||
|
||
/** | ||
* Test on_deactivation method. | ||
* | ||
* @since 0.1.0-alpha | ||
*/ | ||
public function test_on_deactivation() { | ||
WP_Mock::userFunction( 'wp_cache_flush' ); | ||
WP_Mock::userFunction( 'flush_rewrite_rules' ); | ||
private Plugin $plugin; | ||
private Container $container; | ||
|
||
$container = $this->createMock( Container::class ); | ||
$plugin = new Plugin( $container ); | ||
public function setUp(): void { | ||
parent::setUp(); | ||
|
||
$this->assertNull( $plugin->on_deactivation() ); | ||
$this->container = $this->createMock( Container::class ); | ||
$this->plugin = new Plugin( $this->container ); | ||
} | ||
|
||
/** | ||
* Test on_activation method. | ||
* | ||
* @since 0.1.0-alpha | ||
*/ | ||
public function test_on_activation() { | ||
$container = $this->createMock( Container::class ); | ||
$plugin = new Plugin( $container ); | ||
|
||
$this->assertNull( $plugin->on_activation() ); | ||
} | ||
|
||
/** | ||
* Test on_uninstall method. | ||
* | ||
* @since 0.1.0-alpha | ||
*/ | ||
public function test_on_uninstall() { | ||
$this->assertNull( Plugin::on_uninstall() ); | ||
} | ||
|
||
/** | ||
* Test register_services method. | ||
* | ||
* @since 0.1.0-alpha | ||
*/ | ||
public function test_register_services() { | ||
$container = $this->createMock( Container::class ); | ||
$container->method( 'getKnownEntryNames' )->willReturn( array( 'service1', 'service2' ) ); | ||
|
||
$service1 = $this->createMock( Registerable::class ); | ||
$service1->expects( $this->once() )->method( 'register' ); | ||
|
||
$service2 = $this->createMock( Registerable::class ); | ||
$service2->expects( $this->once() )->method( 'register' ); | ||
|
||
$container->method( 'get' )->will( $this->onConsecutiveCalls( $service1, $service2 ) ); | ||
|
||
$plugin = new Plugin( $container ); | ||
$plugin->register_services(); | ||
public function tearDown(): void { | ||
parent::tearDown(); | ||
} | ||
} |
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