Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ public function test_get_directive_entries() {
$p->next_tag();
$results = $get_directive_entries->invoke( $this->interactivity, $p, 'test' );
$this->assertCount( 6, $results );
$this->assertEquals(
$this->assertSame(
array(
array( null, null ),
array( null, 'a' ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,18 +182,18 @@ public function test_set_content_between_balanced_tags_standard_tags() {
$p->next_tag();
$result = $p->set_content_between_balanced_tags( 'New text' );
$this->assertTrue( $result );
$this->assertEquals( '<div>New text</div>', $p );
$this->assertSame( '<div>New text</div>', $p->get_updated_html() );

$content = '<div>Text</div><div>More text</div>';
$p = new WP_Interactivity_API_Directives_Processor( $content );
$p->next_tag();
$result = $p->set_content_between_balanced_tags( 'New text' );
$this->assertTrue( $result );
$this->assertEquals( '<div>New text</div><div>More text</div>', $p );
$this->assertSame( '<div>New text</div><div>More text</div>', $p->get_updated_html() );
$p->next_tag();
$result = $p->set_content_between_balanced_tags( 'More new text' );
$this->assertTrue( $result );
$this->assertEquals( '<div>New text</div><div>More new text</div>', $p );
$this->assertSame( '<div>New text</div><div>More new text</div>', $p->get_updated_html() );
}

/**
Expand All @@ -211,7 +211,7 @@ public function test_set_content_between_balanced_tags_on_closing_tag() {
$p->next_tag( array( 'tag_closers' => 'visit' ) );
$result = $p->set_content_between_balanced_tags( 'New text' );
$this->assertFalse( $result );
$this->assertEquals( '<div>Text</div>', $p );
$this->assertSame( '<div>Text</div>', $p->get_updated_html() );
}

/**
Expand All @@ -228,10 +228,10 @@ public function test_set_content_between_balanced_tags_multiple_calls_in_same_ta
$p->next_tag();
$result = $p->set_content_between_balanced_tags( 'New text' );
$this->assertTrue( $result );
$this->assertEquals( '<div>New text</div>', $p );
$this->assertSame( '<div>New text</div>', $p->get_updated_html() );
$result = $p->set_content_between_balanced_tags( 'More text' );
$this->assertTrue( $result );
$this->assertEquals( '<div>More text</div>', $p );
$this->assertSame( '<div>More text</div>', $p->get_updated_html() );
}

/**
Expand All @@ -249,15 +249,15 @@ public function test_set_content_between_balanced_tags_with_set_attribute() {
$p->set_attribute( 'class', 'test' );
$result = $p->set_content_between_balanced_tags( 'New text' );
$this->assertTrue( $result );
$this->assertEquals( '<div class="test">New text</div>', $p );
$this->assertSame( '<div class="test">New text</div>', $p->get_updated_html() );

$content = '<div>Text</div>';
$p = new WP_Interactivity_API_Directives_Processor( $content );
$p->next_tag();
$result = $p->set_content_between_balanced_tags( 'New text' );
$this->assertTrue( $result );
$p->set_attribute( 'class', 'test' );
$this->assertEquals( '<div class="test">New text</div>', $p );
$this->assertSame( '<div class="test">New text</div>', $p->get_updated_html() );
}

/**
Expand All @@ -274,7 +274,7 @@ public function test_set_content_between_balanced_tags_with_existing_tags() {
$p->next_tag();
$result = $p->set_content_between_balanced_tags( 'New text' );
$this->assertTrue( $result );
$this->assertEquals( '<div>New text</div>', $p );
$this->assertSame( '<div>New text</div>', $p->get_updated_html() );
}

/**
Expand All @@ -291,7 +291,7 @@ public function test_set_content_between_balanced_tags_with_new_tags() {
$p = new WP_Interactivity_API_Directives_Processor( $content );
$p->next_tag();
$p->set_content_between_balanced_tags( $new_content );
$this->assertEquals( '<div>&lt;span&gt;New text&lt;/span&gt;&lt;a href=&quot;#&quot;&gt;Link&lt;/a&gt;</div>', $p );
$this->assertSame( '<div>&lt;span&gt;New text&lt;/span&gt;&lt;a href=&quot;#&quot;&gt;Link&lt;/a&gt;</div>', $p->get_updated_html() );
}

/**
Expand All @@ -307,14 +307,14 @@ public function test_set_content_between_balanced_tags_empty() {
$p->next_tag();
$result = $p->set_content_between_balanced_tags( '' );
$this->assertTrue( $result );
$this->assertEquals( '<div></div>', $p );
$this->assertSame( '<div></div>', $p->get_updated_html() );

$content = '<div><div>Text</div></div>';
$p = new WP_Interactivity_API_Directives_Processor( $content );
$p->next_tag();
$result = $p->set_content_between_balanced_tags( '' );
$this->assertTrue( $result );
$this->assertEquals( '<div></div>', $p );
$this->assertSame( '<div></div>', $p->get_updated_html() );
}

/**
Expand All @@ -330,7 +330,7 @@ public function test_set_content_between_balanced_tags_self_closing_tag() {
$p->next_tag();
$result = $p->set_content_between_balanced_tags( 'New text' );
$this->assertFalse( $result );
$this->assertEquals( $content, $p );
$this->assertSame( $content, $p->get_updated_html() );
}

/**
Expand All @@ -346,7 +346,7 @@ public function test_set_content_between_balanced_tags_non_existent_tag() {
$p->next_tag();
$result = $p->set_content_between_balanced_tags( 'New text' );
$this->assertFalse( $result );
$this->assertEquals( $content, $p );
$this->assertSame( $content, $p->get_updated_html() );
}

/**
Expand All @@ -364,29 +364,29 @@ public function test_set_content_between_balanced_tags_with_unbalanced_tags() {
$p->next_tag();
$result = $p->set_content_between_balanced_tags( $new_content );
$this->assertFalse( $result );
$this->assertEquals( $content, $p );
$this->assertSame( $content, $p->get_updated_html() );

$content = '<div><div>Missing closing div</div>';
$p = new WP_Interactivity_API_Directives_Processor( $content );
$p->next_tag();
$result = $p->set_content_between_balanced_tags( $new_content );
$this->assertFalse( $result );
$this->assertEquals( $content, $p );
$this->assertSame( $content, $p->get_updated_html() );

$content = '<div>Missing closing div</span>';
$p = new WP_Interactivity_API_Directives_Processor( $content );
$p->next_tag();
$result = $p->set_content_between_balanced_tags( $new_content );
$this->assertFalse( $result );
$this->assertEquals( $content, $p );
$this->assertSame( $content, $p->get_updated_html() );

// It supports unbalanced tags inside the content.
$content = '<div>Missing opening span</span></div>';
$p = new WP_Interactivity_API_Directives_Processor( $content );
$p->next_tag();
$result = $p->set_content_between_balanced_tags( $new_content );
$this->assertTrue( $result );
$this->assertEquals( '<div>New text</div>', $p );
$this->assertSame( '<div>New text</div>', $p->get_updated_html() );
}

/**
Expand Down Expand Up @@ -456,7 +456,7 @@ public function test_append_content_after_template_tag_closer_simple_text() {
$p->next_tag( array( 'tag_closers' => 'visit' ) );
$result = $p->append_content_after_template_tag_closer( $content_2 );
$this->assertTrue( $result );
$this->assertEquals( $content_1 . $content_2, $p );
$this->assertSame( $content_1 . $content_2, $p->get_updated_html() );
$this->assertFalse( $p->next_tag() ); // There are no more tags.
}

Expand All @@ -477,14 +477,14 @@ public function test_append_content_after_template_tag_closer_simple_tags() {
$p->next_tag( array( 'tag_closers' => 'visit' ) );
$result = $p->append_content_after_template_tag_closer( $content_2 );
$this->assertTrue( $result );
$this->assertEquals( $content_1 . $content_2, $p );
$this->assertSame( $content_1 . $content_2, $p->get_updated_html() );
$p->next_tag( array( 'tag_closers' => 'visit' ) );
$this->assertSame( 'content-2', $p->get_attribute( 'class' ) );
$p->next_tag( array( 'tag_closers' => 'visit' ) );
$result = $p->append_content_after_template_tag_closer( $content_3 );
$this->assertTrue( $result );
$p->next_tag( array( 'tag_closers' => 'visit' ) );
$this->assertEquals( $content_1 . $content_2 . $content_3, $p );
$this->assertSame( $content_1 . $content_2 . $content_3, $p->get_updated_html() );
$this->assertSame( 'content-3', $p->get_attribute( 'class' ) );
}

Expand All @@ -507,7 +507,7 @@ public function test_append_content_after_template_tag_closer_in_the_middle_of_t
$p->next_tag( array( 'tag_closers' => 'visit' ) );
$result = $p->append_content_after_template_tag_closer( $content_2 );
$this->assertTrue( $result );
$this->assertEquals( $content_1 . $content_2 . $content_3, $p );
$this->assertSame( $content_1 . $content_2 . $content_3, $p->get_updated_html() );
$p->next_tag( array( 'tag_closers' => 'visit' ) );
$this->assertSame( 'content-3', $p->get_attribute( 'class' ) );

Expand All @@ -516,7 +516,7 @@ public function test_append_content_after_template_tag_closer_in_the_middle_of_t
$p->next_tag( array( 'tag_closers' => 'visit' ) );
$result = $p->append_content_after_template_tag_closer( $content_4 );
$this->assertTrue( $result );
$this->assertEquals( $content_1 . $content_4 . $content_3, $p );
$this->assertSame( $content_1 . $content_4 . $content_3, $p->get_updated_html() );
$p->next_tag( array( 'tag_closers' => 'visit' ) );
$this->assertSame( 'content-4', $p->get_attribute( 'class' ) );
}
Expand All @@ -535,7 +535,7 @@ public function test_append_content_after_template_tag_closer_on_opener_tag() {
$p->next_tag( array( 'tag_closers' => 'visit' ) );
$result = $p->append_content_after_template_tag_closer( 'New text' );
$this->assertFalse( $result );
$this->assertEquals( $content, $p );
$this->assertSame( $content, $p->get_updated_html() );
}

/**
Expand All @@ -556,7 +556,7 @@ public function test_append_content_after_template_tag_closer_multiple_calls_in_
$p->next_tag( array( 'tag_closers' => 'visit' ) );
$result = $p->append_content_after_template_tag_closer( $content_2 );
$this->assertTrue( $result );
$this->assertEquals( $content_1 . $content_2, $p );
$this->assertSame( $content_1 . $content_2, $p->get_updated_html() );
$p->next_tag( array( 'tag_closers' => 'visit' ) );
$this->assertSame( 'content-2', $p->get_attribute( 'class' ) );
// Rewinds to the first template.
Expand All @@ -565,7 +565,7 @@ public function test_append_content_after_template_tag_closer_multiple_calls_in_
$this->assertSame( 'content-1', $p->get_attribute( 'class' ) );
$p->next_tag( array( 'tag_closers' => 'visit' ) );
$result = $p->append_content_after_template_tag_closer( $content_3 );
$this->assertEquals( $content_1 . $content_3 . $content_2, $p );
$this->assertSame( $content_1 . $content_3 . $content_2, $p->get_updated_html() );
$p->next_tag( array( 'tag_closers' => 'visit' ) );
$this->assertSame( 'content-3', $p->get_attribute( 'class' ) );
}
Expand All @@ -588,7 +588,7 @@ public function test_append_content_after_template_tag_closer_with_set_attribute
$p->next_tag( array( 'tag_closers' => 'visit' ) );
$result = $p->append_content_after_template_tag_closer( $content_2 );
$this->assertTrue( $result );
$this->assertEquals( '<template class="test">Text</template>' . $content_2, $p );
$this->assertSame( '<template class="test">Text</template>' . $content_2, $p->get_updated_html() );
}

/**
Expand All @@ -613,15 +613,15 @@ public function test_append_content_after_template_tag_closer_with_existing_tags
);
$result = $p->append_content_after_template_tag_closer( $content_2 );
$this->assertTrue( $result );
$this->assertEquals( $content_1 . $content_2, $p );
$this->assertSame( $content_1 . $content_2, $p->get_updated_html() );
$p->next_tag();
$this->assertSame( 'content-2-template-1', $p->get_attribute( 'class' ) );
$p->next_tag();
$this->assertSame( 'content-2-template-2', $p->get_attribute( 'class' ) );
$p->next_tag( array( 'tag_closers' => 'visit' ) );
$result = $p->append_content_after_template_tag_closer( $content_3 );
$this->assertTrue( $result );
$this->assertEquals( $content_1 . '<template class="content-2-template-1"><template class="content-2-template-2">New text</template>' . $content_3 . '</template>', $p );
$this->assertSame( $content_1 . '<template class="content-2-template-1"><template class="content-2-template-2">New text</template>' . $content_3 . '</template>', $p->get_updated_html() );
}

/**
Expand All @@ -639,7 +639,7 @@ public function test_append_content_after_template_tag_closer_empty() {
$p->next_tag( array( 'tag_closers' => 'visit' ) );
$result = $p->append_content_after_template_tag_closer( '' );
$this->assertFalse( $result );
$this->assertEquals( $content, $p );
$this->assertSame( $content, $p->get_updated_html() );
$this->assertSame( 'TEMPLATE', $p->get_tag() ); // It didn't move.
$this->assertTrue( $p->is_tag_closer() ); // It didn't move.
}
Expand All @@ -659,7 +659,7 @@ public function test_append_content_after_template_tag_closer_non_existent_tag()
$p->next_tag();
$result = $p->append_content_after_template_tag_closer( $content_2 );
$this->assertFalse( $result );
$this->assertEquals( $content_1, $p );
$this->assertSame( $content_1, $p->get_updated_html() );
}

/**
Expand All @@ -678,7 +678,7 @@ public function test_append_content_after_template_tag_closer_non_template_tags(
$p->next_tag( array( 'tag_closers' => 'visit' ) );
$result = $p->append_content_after_template_tag_closer( $content_2 );
$this->assertFalse( $result );
$this->assertEquals( $content_1, $p );
$this->assertSame( $content_1, $p->get_updated_html() );
}

/**
Expand Down
Loading