Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions phpunit/block-supports/border-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,26 @@
*/

class WP_Block_Supports_Border_Test extends WP_UnitTestCase {
/**
* @var string|null
*/
private $test_block_name;

function setUp() {
parent::setUp();
$this->test_block_name = null;
}

function tearDown() {
unregister_block_type( $this->test_block_name );
$this->test_block_name = null;
parent::tearDown();
}

function test_border_color_slug_with_numbers_is_kebab_cased_properly() {
$block_name = 'test/border-color-slug-with-numbers-is-kebab-cased-properly';
$this->test_block_name = 'test/border-color-slug-with-numbers-is-kebab-cased-properly';
register_block_type(
$block_name,
$this->test_block_name,
array(
'api_version' => 2,
'attributes' => array(
Expand All @@ -33,7 +48,7 @@ function test_border_color_slug_with_numbers_is_kebab_cased_properly() {
)
);
$registry = WP_Block_Type_Registry::get_instance();
$block_type = $registry->get_registered( $block_name );
$block_type = $registry->get_registered( $this->test_block_name );
$block_atts = array(
'borderColor' => 'red',
'style' => array(
Expand All @@ -52,13 +67,12 @@ function test_border_color_slug_with_numbers_is_kebab_cased_properly() {
);

$this->assertSame( $expected, $actual );
unregister_block_type( $block_name );
}

function test_border_with_skipped_serialization_block_supports() {
$block_name = 'test/border-with-skipped-serialization-block-supports';
$this->test_block_name = 'test/border-with-skipped-serialization-block-supports';
register_block_type(
$block_name,
$this->test_block_name,
array(
'api_version' => 2,
'attributes' => array(
Expand All @@ -78,7 +92,7 @@ function test_border_with_skipped_serialization_block_supports() {
)
);
$registry = WP_Block_Type_Registry::get_instance();
$block_type = $registry->get_registered( $block_name );
$block_type = $registry->get_registered( $this->test_block_name );
$block_atts = array(
'style' => array(
'border' => array(
Expand All @@ -94,13 +108,12 @@ function test_border_with_skipped_serialization_block_supports() {
$expected = array();

$this->assertSame( $expected, $actual );
unregister_block_type( $block_name );
}

function test_radius_with_individual_skipped_serialization_block_supports() {
$block_name = 'test/radius-with-individual-skipped-serialization-block-supports';
$this->test_block_name = 'test/radius-with-individual-skipped-serialization-block-supports';
register_block_type(
$block_name,
$this->test_block_name,
array(
'api_version' => 2,
'attributes' => array(
Expand All @@ -120,7 +133,7 @@ function test_radius_with_individual_skipped_serialization_block_supports() {
)
);
$registry = WP_Block_Type_Registry::get_instance();
$block_type = $registry->get_registered( $block_name );
$block_type = $registry->get_registered( $this->test_block_name );
$block_atts = array(
'style' => array(
'border' => array(
Expand All @@ -138,6 +151,5 @@ function test_radius_with_individual_skipped_serialization_block_supports() {
);

$this->assertSame( $expected, $actual );
unregister_block_type( $block_name );
}
}
35 changes: 24 additions & 11 deletions phpunit/block-supports/colors-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,26 @@
*/

class WP_Block_Supports_Colors_Test extends WP_UnitTestCase {
/**
* @var string|null
*/
private $test_block_name;

function setUp() {
parent::setUp();
$this->test_block_name = null;
}

function tearDown() {
unregister_block_type( $this->test_block_name );
$this->test_block_name = null;
parent::tearDown();
}

function test_color_slugs_with_numbers_are_kebab_cased_properly() {
$this->test_block_name = 'test/color-slug-with-numbers';
register_block_type(
'test/color-slug-with-numbers',
$this->test_block_name,
array(
'api_version' => 2,
'attributes' => array(
Expand All @@ -34,7 +50,7 @@ function test_color_slugs_with_numbers_are_kebab_cased_properly() {
)
);
$registry = WP_Block_Type_Registry::get_instance();
$block_type = $registry->get_registered( 'test/color-slug-with-numbers' );
$block_type = $registry->get_registered( $this->test_block_name );

$block_atts = array(
'textColor' => 'fg1',
Expand All @@ -46,13 +62,12 @@ function test_color_slugs_with_numbers_are_kebab_cased_properly() {
$expected = array( 'class' => 'has-text-color has-fg-1-color has-background has-bg-2-background-color has-background has-gr-3-gradient-background' );

$this->assertSame( $expected, $actual );
unregister_block_type( 'test/color-slug-with-numbers' );
}

function test_color_with_skipped_serialization_block_supports() {
$block_name = 'test/color-with-skipped-serialization-block-supports';
$this->test_block_name = 'test/color-with-skipped-serialization-block-supports';
register_block_type(
$block_name,
$this->test_block_name,
array(
'api_version' => 2,
'attributes' => array(
Expand All @@ -71,7 +86,7 @@ function test_color_with_skipped_serialization_block_supports() {
);

$registry = WP_Block_Type_Registry::get_instance();
$block_type = $registry->get_registered( $block_name );
$block_type = $registry->get_registered( $this->test_block_name );
$block_atts = array(
'style' => array(
'color' => array(
Expand All @@ -85,13 +100,12 @@ function test_color_with_skipped_serialization_block_supports() {
$expected = array();

$this->assertSame( $expected, $actual );
unregister_block_type( $block_name );
}

function test_gradient_with_individual_skipped_serialization_block_supports() {
$block_name = 'test/gradient-with-individual-skipped-serialization-block-support';
$this->test_block_name = 'test/gradient-with-individual-skipped-serialization-block-support';
register_block_type(
$block_name,
$this->test_block_name,
array(
'api_version' => 2,
'attributes' => array(
Expand All @@ -110,7 +124,7 @@ function test_gradient_with_individual_skipped_serialization_block_supports() {
);

$registry = WP_Block_Type_Registry::get_instance();
$block_type = $registry->get_registered( $block_name );
$block_type = $registry->get_registered( $this->test_block_name );
$block_atts = array(
'style' => array(
'color' => array(
Expand All @@ -126,6 +140,5 @@ function test_gradient_with_individual_skipped_serialization_block_supports() {
);

$this->assertSame( $expected, $actual );
unregister_block_type( $block_name );
}
}
36 changes: 24 additions & 12 deletions phpunit/block-supports/spacing-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,26 @@
*/

class WP_Block_Supports_Spacing_Test extends WP_UnitTestCase {
/**
* @var string|null
*/
private $test_block_name;

function setUp() {
parent::setUp();
$this->test_block_name = null;
}

function tearDown() {
unregister_block_type( $this->test_block_name );
$this->test_block_name = null;
parent::tearDown();
}

function test_spacing_style_is_applied() {
$block_name = 'test/spacing-style-is-applied';
$this->test_block_name = 'test/spacing-style-is-applied';
register_block_type(
$block_name,
$this->test_block_name,
array(
'api_version' => 2,
'attributes' => array(
Expand All @@ -29,7 +44,7 @@ function test_spacing_style_is_applied() {
)
);
$registry = WP_Block_Type_Registry::get_instance();
$block_type = $registry->get_registered( $block_name );
$block_type = $registry->get_registered( $this->test_block_name );
$block_atts = array(
'style' => array(
'spacing' => array(
Expand All @@ -51,13 +66,12 @@ function test_spacing_style_is_applied() {
);

$this->assertSame( $expected, $actual );
unregister_block_type( $block_name );
}

function test_spacing_with_skipped_serialization_block_supports() {
$block_name = 'test/spacing-with-skipped-serialization-block-supports';
$this->test_block_name = 'test/spacing-with-skipped-serialization-block-supports';
register_block_type(
$block_name,
$this->test_block_name,
array(
'api_version' => 2,
'attributes' => array(
Expand All @@ -76,7 +90,7 @@ function test_spacing_with_skipped_serialization_block_supports() {
)
);
$registry = WP_Block_Type_Registry::get_instance();
$block_type = $registry->get_registered( $block_name );
$block_type = $registry->get_registered( $this->test_block_name );
$block_atts = array(
'style' => array(
'spacing' => array(
Expand All @@ -96,13 +110,12 @@ function test_spacing_with_skipped_serialization_block_supports() {
$expected = array();

$this->assertSame( $expected, $actual );
unregister_block_type( $block_name );
}

function test_margin_with_individual_skipped_serialization_block_supports() {
$block_name = 'test/margin-with-individual-skipped-serialization-block-supports';
$this->test_block_name = 'test/margin-with-individual-skipped-serialization-block-supports';
register_block_type(
$block_name,
$this->test_block_name,
array(
'api_version' => 2,
'attributes' => array(
Expand All @@ -121,7 +134,7 @@ function test_margin_with_individual_skipped_serialization_block_supports() {
)
);
$registry = WP_Block_Type_Registry::get_instance();
$block_type = $registry->get_registered( $block_name );
$block_type = $registry->get_registered( $this->test_block_name );
$block_atts = array(
'style' => array(
'spacing' => array(
Expand All @@ -143,6 +156,5 @@ function test_margin_with_individual_skipped_serialization_block_supports() {
);

$this->assertSame( $expected, $actual );
unregister_block_type( $block_name );
}
}
Loading