-
Notifications
You must be signed in to change notification settings - Fork 907
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
90 additions
and
0 deletions.
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
tests/Unit/Integrations/Blocks/Block_Editor_Integration_Test.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,90 @@ | ||
<?php | ||
|
||
namespace Yoast\WP\SEO\Tests\Unit\Integrations\Blocks; | ||
|
||
use Brain\Monkey\Functions; | ||
use Mockery; | ||
use WPSEO_Admin_Asset_Manager; | ||
use Yoast\WP\SEO\Integrations\Blocks\Block_Editor_Integration; | ||
use Yoast\WP\SEO\Tests\Unit\TestCase; | ||
|
||
/** | ||
* Test class for block editor integration. | ||
* | ||
* @coversDefaultClass \Yoast\WP\SEO\Integrations\Blocks\Block_Editor_Integration | ||
* | ||
* @group blocks | ||
*/ | ||
final class Block_Editor_Integration_Test extends TestCase { | ||
|
||
/** | ||
* Holds the test instance. | ||
* | ||
* @var Block_Editor_Integration | ||
*/ | ||
protected $instance; | ||
|
||
/** | ||
* Holds the asset manager mock. | ||
* | ||
* @var Mockery\MockInterface|WPSEO_Admin_Asset_Manager | ||
*/ | ||
protected $asset_manager; | ||
|
||
/** | ||
* Sets an instance for testing. | ||
* | ||
* @return void | ||
*/ | ||
public function set_up() { | ||
parent::set_up(); | ||
|
||
$this->asset_manager = Mockery::mock( WPSEO_Admin_Asset_Manager::class ); | ||
|
||
$this->instance = new Block_Editor_Integration( $this->asset_manager ); | ||
} | ||
|
||
/** | ||
* Test constructor. | ||
* | ||
* @covers ::__construct | ||
* | ||
* @return void | ||
*/ | ||
public function test_constructor() { | ||
$this->assertInstanceOf( | ||
WPSEO_Admin_Asset_Manager::class, | ||
$this->getPropertyValue( $this->instance, 'asset_manager' ) | ||
); | ||
} | ||
|
||
/** | ||
* Tests that register_hooks registers the expected hooks. | ||
* | ||
* @covers ::register_hooks | ||
* | ||
* @return void | ||
*/ | ||
public function test_register_hooks() { | ||
Functions\expect( 'add_action' ) | ||
->once() | ||
->with( 'enqueue_block_assets', [ $this->instance, 'enqueue' ] ); | ||
|
||
$this->instance->register_hooks(); | ||
} | ||
|
||
/** | ||
* Tests that enqueue enqueues the expected assets. | ||
* | ||
* @covers ::enqueue | ||
* | ||
* @return void | ||
*/ | ||
public function test_enqueue() { | ||
$this->asset_manager->expects( 'enqueue_style' ) | ||
->once() | ||
->with( 'block-editor' ); | ||
|
||
$this->instance->enqueue(); | ||
} | ||
} |