Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vraja-pro committed Nov 22, 2024
1 parent 606bb63 commit 8d8201d
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions tests/Unit/Integrations/Blocks/Block_Editor_Integration_Test.php
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();
}
}

0 comments on commit 8d8201d

Please sign in to comment.