Skip to content

Commit

Permalink
Try fixing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
miina committed Mar 19, 2018
1 parent 3d75fe3 commit 93f77fc
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions tests/test-class-amp-core-block-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,32 @@ class Test_AMP_Core_Block_Handler extends WP_UnitTestCase {
*/
public $test_block = 'core/test';

/**
* Setup.
*/
public function setUp() {
parent::setUp();

// Require gutenberg file to be able to run the tests.
if ( file_exists( AMP__DIR__ . '/../gutenberg/gutenberg.php' ) ) {
require_once AMP__DIR__ . '/../gutenberg/gutenberg.php';

if ( ! function_exists( 'register_block_type' ) ) {
require_once AMP__DIR__ . '/../gutenberg/lib/class-wp-block-type.php';
require_once AMP__DIR__ . '/../gutenberg/lib/class-wp-block-type-registry.php';
require_once AMP__DIR__ . '/../gutenberg/lib/blocks.php';
}
}
}

/**
* Teardown.
*/
public function tearDown() {
$this->unregister_dummy_block();
if ( function_exists( 'register_block_type' ) ) {
$this->unregister_dummy_block();
}

parent::tearDown();
}

Expand All @@ -67,6 +79,10 @@ public function unregister_dummy_block() {
*/
public function test_register_embed() {

if ( ! function_exists( 'register_block_type' ) ) {
$this->markTestIncomplete( 'Files needed for testing missing.' );
}

$this->register_dummy_block();

$this->instance = new AMP_Core_Block_Handler();
Expand All @@ -91,6 +107,10 @@ public function test_register_embed() {
* Test unregister_embed().
*/
public function test_unregister_embed() {
if ( ! function_exists( 'register_block_type' ) ) {
$this->markTestIncomplete( 'Files needed for testing missing.' );
}

$this->register_dummy_block();

$this->instance = new AMP_Core_Block_Handler();
Expand All @@ -102,7 +122,7 @@ public function test_unregister_embed() {
$registry = WP_Block_Type_Registry::get_instance();
$block = $registry->get_registered( $this->test_block );

$this->assertEquals( '__return_true', $block->render_callback );
$this->assertEquals( '__return_true', $block->render_callback );

$this->unregister_dummy_block();
}
Expand Down

0 comments on commit 93f77fc

Please sign in to comment.