user->create( array( 'role' => 'administrator' ) ); if ( is_multisite() ) { grant_super_admin( self::$admin_id ); } } /** * @dataProvider data_items_that_are_not_footnotes * @covers ::gutenberg_render_block_core_footnotes * * @link https://github.com/WordPress/gutenberg/issues/86713 * * @param string $footnotes The footnotes meta, as JSON. */ public function test_skips_items_that_are_not_footnotes( $footnotes ) { $post_id = $this->create_post_with_footnotes_meta( $footnotes ); $this->assertSame( '', $this->render_footnotes_block( $post_id ) ); } /** * Data provider for test_skips_items_that_are_not_footnotes(). * * @return array[] */ public function data_items_that_are_not_footnotes() { return array( 'a string' => array( '["text"]' ), 'null' => array( '[null]' ), 'a number' => array( '[1]' ), 'a footnote without an id' => array( '[{"content":"No id"}]' ), 'an id that is not a string' => array( '[{"id":["x"],"content":"x"}]' ), 'an empty id' => array( '[{"id":"","content":"x"}]' ), ); } /** * @covers ::gutenberg_render_block_core_footnotes * * @link https://github.com/WordPress/gutenberg/issues/86713 */ public function test_numbers_footnotes_without_the_items_that_are_skipped() { $post_id = $this->create_post_with_footnotes_meta( '[null,{"id":"fn-a","content":"A note."}]' ); $output = $this->render_footnotes_block( $post_id ); $this->assertSame( 1, substr_count( $output, '