Skip to content

Commit

Permalink
[MOOSE-114]: Add extra tests and stub for acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MlKilderkin committed Aug 13, 2024
1 parent d1c7e1c commit b4dc43e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/_data/editor_asset_test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '024bef6fb3a0bc82cb17');
8 changes: 8 additions & 0 deletions tests/acceptance/ExampleCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php declare(strict_types=1);

class ExampleCest {
public function test_it_works( AcceptanceTester $I ): void {
$I->amOnPage('/');
}

}
38 changes: 38 additions & 0 deletions tests/wpunit/BlockBaseWpUnitTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php declare(strict_types=1);

class BlockBaseWpUnitTest extends \Codeception\TestCase\WPTestCase {

use \Tribe\Plugin\Assets\Traits\Assets;

public function setUp(): void {
parent::setUp();

$block_dir = get_template_directory() . '/dist/blocks/core/button';
$editor_asset = $block_dir . '/editor.asset.php';
mkdir( $block_dir, 0777, true );

$editor_asset_content = file_get_contents( __DIR__ . '/../_data/editor_asset_test.php' );
$file_handler = fopen( $editor_asset, 'w' );
fwrite( $file_handler, $editor_asset_content );
fclose( $file_handler );
}

public function test_editor_styles_can_get_version_from_asset_php()
{
$args = $this->get_asset_file_args( get_theme_file_path( "dist/blocks/core/button/editor.asset.php" ) );
self::assertArrayHasKey( 'version', $args );
$version = $args['version'] ?? false;
self::assertEquals( '024bef6fb3a0bc82cb17', $version );
}

protected function tearDown(): void {
parent::tearDown();

$block_dir = get_template_directory() . '/dist/blocks/core/button';
$editor_asset = $block_dir . '/editor.asset.php';

unlink( $editor_asset );
rmdir( $block_dir );
}

}

0 comments on commit b4dc43e

Please sign in to comment.