Repository navigation
XML-RPC: Use instanceof instead of is_a() in IXR. #15203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
eecd88d
XML-RPC: Use instanceof instead of is_a() in IXR.
dhrupo d5a5f06
XML-RPC: Use instanceof in IXR_Value::calculateType().
westonruter f1592d4
Tests: Cover IXR class checks on non-object values.
westonruter ae3859d
Revisions: Use instanceof instead of is_a() in Text_Diff.
dhrupo 06c95fe
Merge branch 'trunk' into php86-ixr-is-a
westonruter 62cfd01
Narrow types in test
westonruter 6ce7beb
Merge branch 'trunk' into php86-ixr-is-a
peterwilsoncc 567ed84
Add messages to new tests.
peterwilsoncc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Tests for the edit class checks in Text_Diff and Text_Diff_Renderer. | ||
| * | ||
| * @group diff | ||
| */ | ||
| final class Tests_Diff_TextDiff extends WP_UnitTestCase { | ||
|
|
||
| public static function set_up_before_class() { | ||
| parent::set_up_before_class(); | ||
|
|
||
| require_once ABSPATH . 'wp-includes/Text/Diff.php'; | ||
| require_once ABSPATH . 'wp-includes/Text/Diff/Renderer.php'; | ||
| } | ||
|
|
||
| /** | ||
| * @ticket 66418 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a one line summary at the top of each test. For this one it might be: 🔢 Applies to other tests too. |
||
| * | ||
| * @covers Text_Diff::countAddedLines | ||
| * @covers Text_Diff::countDeletedLines | ||
| * @covers Text_Diff::isEmpty | ||
| * @covers Text_Diff::lcs | ||
| * | ||
| * @dataProvider data_edit_counts | ||
| * | ||
| * @param non-empty-string[] $from_lines Lines before the change. | ||
| * @param non-empty-string[] $to_lines Lines after the change. | ||
| * @param non-negative-int $added Expected number of added lines. | ||
| * @param non-negative-int $deleted Expected number of deleted lines. | ||
| * @param bool $is_empty Whether the diff is expected to have no changes. | ||
| * @param non-negative-int $unchanged_lines Expected number of unchanged lines. | ||
| */ | ||
| public function test_edit_counts( array $from_lines, array $to_lines, int $added, int $deleted, bool $is_empty, int $unchanged_lines ) { | ||
| $diff = new Text_Diff( 'native', array( $from_lines, $to_lines ) ); | ||
|
|
||
| $this->assertSame( $added, $diff->countAddedLines(), 'Added lines do not match.' ); | ||
| $this->assertSame( $deleted, $diff->countDeletedLines(), 'Deleted lines do not match.' ); | ||
| $this->assertSame( $is_empty, $diff->isEmpty(), 'isEmpty() does not match.' ); | ||
| $this->assertSame( $unchanged_lines, $diff->lcs(), 'Unchanged lines do not match.' ); | ||
| } | ||
|
|
||
| /** | ||
| * Data provider for {@see self::test_edit_counts()}. | ||
| * | ||
| * @return array<non-falsy-string, array{ non-empty-string[], non-empty-string[], non-negative-int, non-negative-int, bool, non-negative-int }> | ||
| */ | ||
| public static function data_edit_counts(): array { | ||
| return array( | ||
| 'both empty' => array( array(), array(), 0, 0, true, 0 ), | ||
| 'identical' => array( array( 'a', 'b' ), array( 'a', 'b' ), 0, 0, true, 2 ), | ||
| 'add only' => array( array( 'a' ), array( 'a', 'b' ), 1, 0, false, 1 ), | ||
| 'delete only' => array( array( 'a', 'b' ), array( 'a' ), 0, 1, false, 1 ), | ||
| 'changed only' => array( array( 'a', 'b', 'c' ), array( 'x', 'b', 'z' ), 2, 2, false, 1 ), | ||
| 'change, copy and add' => array( array( 'a', 'b' ), array( 'x', 'b', 'c' ), 2, 1, false, 1 ), | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * @ticket 66418 | ||
| * | ||
| * @covers Text_Diff_Renderer::render | ||
| */ | ||
| public function test_render_keeps_context_lines_from_copied_blocks() { | ||
| $diff = new Text_Diff( 'native', array( array( 'a', 'b', 'c', 'd', 'e' ), array( 'a', 'b', 'X', 'd', 'e' ) ) ); | ||
| $renderer = new Text_Diff_Renderer( | ||
| array( | ||
| 'leading_context_lines' => 1, | ||
| 'trailing_context_lines' => 1, | ||
| ) | ||
| ); | ||
|
|
||
| $this->assertSame( "2,4c2,4\n b\n< c\n---\n> X\n d\n", $renderer->render( $diff ) ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.