diff --git a/js/blocks/loader/attributes.js b/js/blocks/loader/attributes.js index 6ab6ccaae..eefc499d9 100644 --- a/js/blocks/loader/attributes.js +++ b/js/blocks/loader/attributes.js @@ -1,7 +1,7 @@ /** * Gets the attributes for a block, based on given fields. * - * @param {Object} fields The fields to get the attributes from. + * @param {Object} fields The fields to get the attributes from. * @return {Object} attributes The attributes for the fields. */ const getBlockAttributes = ( fields ) => { diff --git a/php/post-types/class-block-post.php b/php/post-types/class-block-post.php index 12b06b69a..8156529fa 100644 --- a/php/post-types/class-block-post.php +++ b/php/post-types/class-block-post.php @@ -338,7 +338,7 @@ public function add_meta_boxes() { 'default' ); - if ( isset( $post->post_name ) && ! empty( $post->post_name ) ) { + if ( ! empty( $post->post_name ) ) { $locations = block_lab()->get_template_locations( $post->post_name ); $template = block_lab()->locate_template( $locations, '', true ); diff --git a/tests/php/integration/fixtures/repeater-all-fields.php b/tests/php/integration/fixtures/repeater-all-fields.php index 4020deb0b..182260bce 100644 --- a/tests/php/integration/fixtures/repeater-all-fields.php +++ b/tests/php/integration/fixtures/repeater-all-fields.php @@ -29,8 +29,14 @@ diff --git a/tests/php/integration/test-repeater-template-output.php b/tests/php/integration/test-repeater-template-output.php index 210f2ceb3..f965e0156 100644 --- a/tests/php/integration/test-repeater-template-output.php +++ b/tests/php/integration/test-repeater-template-output.php @@ -181,6 +181,14 @@ public function get_block_config() { * This has a repeater with 2 rows, and tests every possible field. * It sets mock block attributes, like those that would be saved from a block. * Then, it loads the mock template in the theme's blocks/ directory and asserts the values. + * + * @covers \block_rows() + * @covers \block_row() + * @covers \reset_block_row() + * @covers \block_row_field() + * @covers \block_row_value() + * @covers \block_row_index() + * @covers \block_row_count() */ public function test_repeater_template() { $block = new Blocks\Block(); @@ -189,12 +197,32 @@ public function test_repeater_template() { $actual_template = str_replace( array( "\t", "\n" ), '', $rendered_template ); $rows = $this->attributes[ self::REPEATER_FIELD_NAME ]['rows']; + $this->assertContains( + sprintf( + 'block_row_count() returns %d', + count( $rows ) + ), + $actual_template + ); + // The 'className' should be present. $this->assertContains( sprintf( '
', $this->class_name ), $actual_template ); + // Test that block_row_index() returns the right row index. + foreach ( $rows as $row_number => $row ) { + $this->assertContains( + sprintf( + 'In row %d, the result of block_row_index() is %d', + $row_number, + $row_number + ), + $actual_template + ); + } + // Test the fields that return a string for block_sub_value(). foreach ( $rows as $row_number => $row ) { foreach ( $this->string_fields as $field ) { diff --git a/tests/php/integration/test-template-output.php b/tests/php/integration/test-template-output.php index f09ab8a62..b3ebfb3da 100644 --- a/tests/php/integration/test-template-output.php +++ b/tests/php/integration/test-template-output.php @@ -139,6 +139,9 @@ public function get_block_config() { * This sets mock block attributes, like those that would be saved from a block. * Then, it loads the mock template in the theme's blocks/ directory, * and ensures that all of these fields appear correctly in it. + * + * @covers \block_field() + * @covers \block_value() */ public function test_block_template() { $block = new Blocks\Block(); diff --git a/tests/php/unit/blocks/test-class-loader.php b/tests/php/unit/blocks/test-class-loader.php index 9a86acf2c..f8f042185 100644 --- a/tests/php/unit/blocks/test-class-loader.php +++ b/tests/php/unit/blocks/test-class-loader.php @@ -19,6 +19,19 @@ class Test_Loader extends Abstract_Template { */ public $instance; + /** + * Test init. + * + * @covers \Block_Lab\Blocks\Loader::init() + */ + public function test_init() { + $this->assertEquals( 'Block_Lab\\Blocks\\Loader', get_class( $this->instance->init() ) ); + $this->assertContains( 'js/editor.blocks.js', $this->instance->assets['path']['entry'] ); + $this->assertContains( 'css/blocks.editor.css', $this->instance->assets['path']['editor_style'] ); + $this->assertContains( 'js/editor.blocks.js', $this->instance->assets['url']['entry'] ); + $this->assertContains( 'css/blocks.editor.css', $this->instance->assets['url']['editor_style'] ); + } + /** * Test register_hooks. *