From 8c5ef90cf138c4cd1e8af222b148e2e0f7873cb7 Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Wed, 5 May 2021 15:28:07 +0000 Subject: [PATCH 01/25] Adding unit-test for vipgoci_cached_indication_str() --- tests/MiscCachedIndicationStrTest.php | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/MiscCachedIndicationStrTest.php diff --git a/tests/MiscCachedIndicationStrTest.php b/tests/MiscCachedIndicationStrTest.php new file mode 100644 index 000000000..fa7571e16 --- /dev/null +++ b/tests/MiscCachedIndicationStrTest.php @@ -0,0 +1,35 @@ +assertsame( + ' (cached)', + vipgoci_cached_indication_str( + true + ) + ); + + $this->assertsame( + ' (cached)', + vipgoci_cached_indication_str( + array( 1, 2, 3 ), + ) + ); + + $this->assertsame( + '', + vipgoci_cached_indication_str( + false, + ) + ); + } +} From d5b9dfc820dc165cd99b27e4f8edb292dc84226f Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Wed, 5 May 2021 15:32:26 +0000 Subject: [PATCH 02/25] Add namespace, disable a particular PHPCS sniff --- tests/Skeleton.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/Skeleton.php b/tests/Skeleton.php index 73e9525a5..404f413ff 100644 --- a/tests/Skeleton.php +++ b/tests/Skeleton.php @@ -1,9 +1,13 @@ Date: Wed, 5 May 2021 15:32:50 +0000 Subject: [PATCH 03/25] Disable a certain PHPCS sniff --- tests/MiscCachedIndicationStrTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/MiscCachedIndicationStrTest.php b/tests/MiscCachedIndicationStrTest.php index fa7571e16..575b51b55 100644 --- a/tests/MiscCachedIndicationStrTest.php +++ b/tests/MiscCachedIndicationStrTest.php @@ -6,6 +6,8 @@ use PHPUnit\Framework\TestCase; +// phpcs:disable PSR1.Files.SideEffects + final class MiscCachedIndicationStrTest extends TestCase { /** * @covers ::vipgoci_cached_indication_str From 060522a2c111aca89f6f0d6737ebacf9345e9667 Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Wed, 5 May 2021 16:48:35 +0000 Subject: [PATCH 04/25] Adding unit-test for vipgoci_github_rate_limit_usage() --- github-api.php | 2 - tests/GitHubRateLimitUsageTest.php | 67 ++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 tests/GitHubRateLimitUsageTest.php diff --git a/github-api.php b/github-api.php index e34663fcf..8a14b4cce 100644 --- a/github-api.php +++ b/github-api.php @@ -155,8 +155,6 @@ function vipgoci_github_rate_limits_check( * * The results are not cached, as we want fresh data * every time. - * - * @codeCoverageIgnore */ function vipgoci_github_rate_limit_usage( diff --git a/tests/GitHubRateLimitUsageTest.php b/tests/GitHubRateLimitUsageTest.php new file mode 100644 index 000000000..a62c8ce3c --- /dev/null +++ b/tests/GitHubRateLimitUsageTest.php @@ -0,0 +1,67 @@ +options = array(); + + $this->options[ 'github-token' ] = + vipgoci_unittests_get_config_value( + 'git-secrets', + 'github-token', + true // Fetch from secrets file + ); + + $this->options['token'] = + $this->options['github-token']; + } + + protected function tearDown(): void { + $this->options = null; + } + + /** + * @covers ::vipgoci_github_rate_limit_usage + */ + public function testGitHubRateLimitUsage1 () { + $options_test = vipgoci_unittests_options_test( + $this->options, + array( ), + $this + ); + + if ( -1 === $options_test ) { + return; + } + + $gh_result = vipgoci_github_rate_limit_usage( + $this->options['github-token'] + ); + + $this->assertTrue( + isset( + $gh_result->resources->core->used + ) + ); + + $this->assertTrue( + isset( + $gh_result->resources->core->limit + ) + ); + + $this->assertTrue( + isset( + $gh_result->resources->core->remaining + ) + ); + } +} + From 51448000df18a28710129ca2904600eac59d0c26 Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Wed, 5 May 2021 16:54:35 +0000 Subject: [PATCH 05/25] Adding test for vipgoci_github_authenticated_user_get() --- tests/GitHubAuthenticatedUserGetTest.php | 55 ++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/GitHubAuthenticatedUserGetTest.php diff --git a/tests/GitHubAuthenticatedUserGetTest.php b/tests/GitHubAuthenticatedUserGetTest.php new file mode 100644 index 000000000..5d481ad16 --- /dev/null +++ b/tests/GitHubAuthenticatedUserGetTest.php @@ -0,0 +1,55 @@ +options = array(); + + $this->options[ 'github-token' ] = + vipgoci_unittests_get_config_value( + 'git-secrets', + 'github-token', + true // Fetch from secrets file + ); + + $this->options['token'] = + $this->options['github-token']; + } + + protected function tearDown(): void { + $this->options = null; + } + + /** + * @covers ::vipgoci_github_authenticated_user_get + */ + public function testGitHubAuthenticatedUserGet1 () { + $options_test = vipgoci_unittests_options_test( + $this->options, + array( ), + $this + ); + + if ( -1 === $options_test ) { + return; + } + + $gh_result = vipgoci_github_authenticated_user_get( + $this->options['github-token'] + ); + + $this->assertTrue( + isset( + $gh_result->login + ) + ); + } +} + From 988d9d256b2c2c0b0d74a035197af32ff2b919a6 Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Wed, 5 May 2021 16:59:44 +0000 Subject: [PATCH 06/25] Code coverage not possible for vipgoci_curl_set_security_options() This is because PHP cURL does not have a way to retrieve a setting. --- github-api.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/github-api.php b/github-api.php index 8a14b4cce..422ee49d3 100644 --- a/github-api.php +++ b/github-api.php @@ -94,6 +94,8 @@ function vipgoci_curl_headers( $ch, $header ) { /* * Set a few options for cURL that enhance security. + * + * @codeCoverageIgnore */ function vipgoci_curl_set_security_options( $ch ) { /* From 6b1b964a1a829f273f6965da48664f406460d3c9 Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Wed, 5 May 2021 18:17:42 +0000 Subject: [PATCH 07/25] Use assertSame() --- tests/MiscCachedIndicationStrTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/MiscCachedIndicationStrTest.php b/tests/MiscCachedIndicationStrTest.php index 575b51b55..946a10a5c 100644 --- a/tests/MiscCachedIndicationStrTest.php +++ b/tests/MiscCachedIndicationStrTest.php @@ -13,21 +13,21 @@ final class MiscCachedIndicationStrTest extends TestCase { * @covers ::vipgoci_cached_indication_str */ public function testCachedIndicationStr1() { - $this->assertsame( + $this->assertSame( ' (cached)', vipgoci_cached_indication_str( true ) ); - $this->assertsame( + $this->assertSame( ' (cached)', vipgoci_cached_indication_str( array( 1, 2, 3 ), ) ); - $this->assertsame( + $this->assertSame( '', vipgoci_cached_indication_str( false, From 74df7b97d72b915f6875872acdb9c2972de25f5c Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Fri, 7 May 2021 09:17:44 +0000 Subject: [PATCH 08/25] Adding test for vipgoci_option_skip_folder_handle() --- tests/OptionsSkipFolderHandleTest.php | 61 +++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 tests/OptionsSkipFolderHandleTest.php diff --git a/tests/OptionsSkipFolderHandleTest.php b/tests/OptionsSkipFolderHandleTest.php new file mode 100644 index 000000000..b1ce8b6d2 --- /dev/null +++ b/tests/OptionsSkipFolderHandleTest.php @@ -0,0 +1,61 @@ +options = array(); + } + + protected function tearDown(): void { + $this->options = null; + } + + /** + * @covers ::vipgoci_option_skip_folder_handle + */ + public function testOptionSkipFolderHandle1() { + $this->options['phpcs-skip-folders'] = + 'var/tmp/,/client-mu-plugins/myplugin/,/plugins/myplugin/,/tmp/1,tmp/3'; + + $this->options['lint-skip-folders'] = + 'var/tmp2/,/client-mu-plugins/otherplugin/,/plugins/otherplugin/,/tmp/2,tmp/4'; + + vipgoci_option_skip_folder_handle( + $this->options, + 'phpcs-skip-folders' + ); + + vipgoci_option_skip_folder_handle( + $this->options, + 'lint-skip-folders' + ); + + $this->assertSame( + array( + 'phpcs-skip-folders' => array( + 'var/tmp', + 'client-mu-plugins/myplugin', + 'plugins/myplugin', + 'tmp/1', + 'tmp/3', + ), + + 'lint-skip-folders' => array( + 'var/tmp2', + 'client-mu-plugins/otherplugin', + 'plugins/otherplugin', + 'tmp/2', + 'tmp/4', + ), + ), + $this->options + ); + } +} From df396301c2f45d2492cff047a85ccca061ff2ac6 Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Fri, 7 May 2021 10:43:22 +0000 Subject: [PATCH 09/25] Adding test for vipgoci_results_filter_comments_to_max() --- tests/ResultsFilterCommentsToMaxTest.php | 247 +++++++++++++++++++++++ 1 file changed, 247 insertions(+) create mode 100644 tests/ResultsFilterCommentsToMaxTest.php diff --git a/tests/ResultsFilterCommentsToMaxTest.php b/tests/ResultsFilterCommentsToMaxTest.php new file mode 100644 index 000000000..6ed696c9b --- /dev/null +++ b/tests/ResultsFilterCommentsToMaxTest.php @@ -0,0 +1,247 @@ + null, + 'repo-name' => null, + ); + + var $options_git_repo_tests = array( + 'pr-test-github-pr-results-max' => null, + ); + + protected function setUp(): void { + vipgoci_unittests_get_config_values( + 'git', + $this->options_git + ); + + vipgoci_unittests_get_config_values( + 'git-repo-tests', + $this->options_git_repo_tests + ); + + $this->options = array_merge( + $this->options_git, + $this->options_git_repo_tests + ); + + $this->options['token'] = + vipgoci_unittests_get_config_value( + 'git-secrets', + 'github-token', + true // Fetch from secrets file + ); + + $this->results = array( + 'issues' => array( + $this->options['pr-test-github-pr-results-max'] => array( + array( + 'type' => 'phpcs', + 'file_name' => 'bla-8.php', + 'file_line' => 9, + 'issue' => array( + 'message' => 'This comment is 36% valid code; is this commented out code?', + 'source' => 'Squiz.PHP.CommentedOutCode.Found', + 'severity' => 1, + 'fixable' => false, + 'type' => 'WARNING', + 'line' => 9, + 'column' => 1, + 'level' => 'WARNING' + ), + ), + + array( + 'type' => 'phpcs', + 'file_name' => 'bla-9.php', + 'file_line' => 10, + 'issue' => array( + 'message' => 'This comment is 100% valid code; is this commented out code?', + 'source' => 'Squiz.PHP.CommentedOutCode.Found', + 'severity' => 10, + 'fixable' => false, + 'type' => 'WARNING', + 'line' => 10, + 'column' => 1, + 'level' => 'WARNING' + ), + ), + ) + ), + + 'stats' => array( + 'phpcs' => array( + $this->options['pr-test-github-pr-results-max'] => array( + 'error' => 0, + 'warning' => 2, + 'info' => 0, + ) + ) + ), + ); + + $this->results_orig = $this->results; + } + + protected function tearDown(): void { + $this->options = null; + $this->options_git = null; + $this->options_git_repo_tests = null; + $this->results = null; + $this->results_orig = null; + } + + /** + * @covers ::vipgoci_results_filter_comments_to_max + */ + public function testResultsFilterCommentsToMax1() { + /* + * Test with max 1 comments allowed. + */ + $this->options['review-comments-total-max'] = 1; + + $prs_comments_maxed = array(); + + vipgoci_results_filter_comments_to_max( + $this->options, + $this->results, + $prs_comments_maxed + ); + + $this->assertSame( + array( + $this->options['pr-test-github-pr-results-max'] => true, + ), + $prs_comments_maxed + ); + + $this->assertSame( + array( + 'issues' => array( + $this->options['pr-test-github-pr-results-max'] => array( + ) + ), + + 'stats' => array( + 'phpcs' => array( + $this->options['pr-test-github-pr-results-max'] => array( + 'error' => 0, + 'warning' => 0, + 'info' => 0, + ) + ) + ) + ), + $this->results + ); + } + + /** + * @covers ::vipgoci_results_filter_comments_to_max + */ + public function testResultsFilterCommentsToMax2() { + /* + * Exactly one more comment allowed. + */ + $comments_count = count( + vipgoci_github_pr_reviews_comments_get_by_pr( + $this->options, + $this->options['pr-test-github-pr-results-max'], + array( + 'login' => 'myself', + 'comments_active' => true, + ) + ) + ); + + $this->options['review-comments-total-max'] = $comments_count + 1; + + $prs_comments_maxed = array(); + + vipgoci_results_filter_comments_to_max( + $this->options, + $this->results, + $prs_comments_maxed + ); + + $this->assertSame( + array( + $this->options['pr-test-github-pr-results-max'] => true, + ), + $prs_comments_maxed + ); + + $this->assertSame( + array( + 'issues' => array( + $this->options['pr-test-github-pr-results-max'] => array( + array( + 'type' => 'phpcs', + 'file_name' => 'bla-9.php', + 'file_line' => 10, + 'issue' => array( + 'message' => 'This comment is 100% valid code; is this commented out code?', + 'source' => 'Squiz.PHP.CommentedOutCode.Found', + 'severity' => 10, + 'fixable' => false, + 'type' => 'WARNING', + 'line' => 10, + 'column' => 1, + 'level' => 'WARNING' + ), + ), + ) + ), + + 'stats' => array( + 'phpcs' => array( + $this->options['pr-test-github-pr-results-max'] => array( + 'error' => 0, + 'warning' => 1, + 'info' => 0, + ) + ) + ) + ), + $this->results + ); + } + + /** + * @covers ::vipgoci_results_filter_comments_to_max + */ + public function testResultsFilterCommentsToMax3() { + /* + * Max 100 allowed + */ + $this->options['review-comments-total-max'] = 100; + + $prs_comments_maxed = array(); + + vipgoci_results_filter_comments_to_max( + $this->options, + $this->results, + $prs_comments_maxed + ); + + $this->assertSame( + array( + ), + $prs_comments_maxed + ); + + $this->assertSame( + $this->results_orig, + $this->results + ); + } +} From 303a4c94dfe8247f0ed32c519f1d53f2e67f447e Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Fri, 7 May 2021 10:44:05 +0000 Subject: [PATCH 10/25] Adding config option for test --- unittests.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/unittests.ini b/unittests.ini index c96508e7b..0e03bc8d4 100644 --- a/unittests.ini +++ b/unittests.ini @@ -88,6 +88,7 @@ commit-test-options-read-repo-skip-files-2=ac10d1f29e64504d7741cd8ca22981c426c26 commit-test-repo-branch=ap-file-types-test-1 commit-test-submodule-list-get-1=f2008d8519d998d9e38f5688aaa2c5322179a266 commit-test-submodule-list-get-2=dd18779e980f0302ab4acf7e871d2062d86b5f58 +pr-test-github-pr-results-max=28 [labels] labels-pr-to-modify=12 From 75ef19bc15fa0eb304894fcc6b2b18f6aa4bd259 Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Fri, 7 May 2021 10:47:26 +0000 Subject: [PATCH 11/25] Replacing assertEquals() with assertSame() --- tests/VipgociOptionsArrayHandleTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/VipgociOptionsArrayHandleTest.php b/tests/VipgociOptionsArrayHandleTest.php index 0e7569fc2..5be866c3f 100644 --- a/tests/VipgociOptionsArrayHandleTest.php +++ b/tests/VipgociOptionsArrayHandleTest.php @@ -20,7 +20,7 @@ public function testOptionsArrayHandle1() { ',' ); - $this->assertEquals( + $this->assertSame( array( 'myvalue', ), @@ -44,7 +44,7 @@ public function testOptionsArrayHandle2() { ',' ); - $this->assertEquals( + $this->assertSame( array( 'myvalue1', 'myvalue2', @@ -70,7 +70,7 @@ public function testOptionsArrayHandle3() { ',' ); - $this->assertEquals( + $this->assertSame( array( 'myvalue1', 'myvalue2', @@ -97,7 +97,7 @@ public function testOptionsArrayHandle4() { false // do not strtolower() ); - $this->assertEquals( + $this->assertSame( array( 'myvalue1', 'myvalue2', From 3038c33b8e49d08a4b02d7d92fc7b74c7380240f Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Fri, 7 May 2021 10:48:39 +0000 Subject: [PATCH 12/25] Replacing assertEquals() with assertSame() --- ...canValidateSniffsInOptionAndReportTest.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/PhpcsScanValidateSniffsInOptionAndReportTest.php b/tests/PhpcsScanValidateSniffsInOptionAndReportTest.php index 54776091e..977031d7f 100644 --- a/tests/PhpcsScanValidateSniffsInOptionAndReportTest.php +++ b/tests/PhpcsScanValidateSniffsInOptionAndReportTest.php @@ -168,7 +168,7 @@ public function testPhpcsValidateIncludeSniffsWithErrors() { $pr_item->number ); - $this->assertEquals( + $this->assertSame( 0, count( array_keys( $pr_comments ) ) ); @@ -250,13 +250,13 @@ public function testPhpcsValidateIncludeSniffsWithErrors() { } // Make sure we removed one comment - $this->assertEquals( + $this->assertSame( 1, $removed_comments ); } - $this->assertEquals( + $this->assertSame( $this->options['phpcs-validate-sniffs-and-report-include-valid'], $this->options['phpcs-sniffs-include'] ); @@ -312,7 +312,7 @@ public function testPhpcsValidateIncludeSniffsNoErrors() { $pr_item->number ); - $this->assertEquals( + $this->assertSame( 0, count( array_keys( $pr_comments ) ) ); @@ -347,13 +347,13 @@ public function testPhpcsValidateIncludeSniffsNoErrors() { $pr_item->number ); - $this->assertEquals( + $this->assertSame( 0, count( array_keys( $pr_comments ) ) ); } - $this->assertEquals( + $this->assertSame( $this->options['phpcs-validate-sniffs-and-report-include-valid'], $this->options['phpcs-sniffs-include'] ); @@ -409,7 +409,7 @@ public function testPhpcsValidateExcludeSniffsWithErrors() { $pr_item->number ); - $this->assertEquals( + $this->assertSame( 0, count( array_keys( $pr_comments ) ) ); @@ -491,13 +491,13 @@ public function testPhpcsValidateExcludeSniffsWithErrors() { } // Make sure we removed one comment - $this->assertEquals( + $this->assertSame( 1, $removed_comments ); } - $this->assertEquals( + $this->assertSame( $this->options['phpcs-validate-sniffs-and-report-exclude-valid'], $this->options['phpcs-sniffs-exclude'] ); @@ -553,7 +553,7 @@ public function testPhpcsValidateExcludeSniffsNoErrors() { $pr_item->number ); - $this->assertEquals( + $this->assertSame( 0, count( array_keys( $pr_comments ) ) ); @@ -588,13 +588,13 @@ public function testPhpcsValidateExcludeSniffsNoErrors() { $pr_item->number ); - $this->assertEquals( + $this->assertSame( 0, count( array_keys( $pr_comments ) ) ); } - $this->assertEquals( + $this->assertSame( $this->options['phpcs-validate-sniffs-and-report-exclude-valid'], $this->options['phpcs-sniffs-exclude'] ); From 34f28bd78d4c137b161738ccc72cff04f78a0b38 Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Fri, 7 May 2021 10:49:39 +0000 Subject: [PATCH 13/25] Replacing assertEquals() with assertSame() --- tests/ResultsSortBySeverityTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ResultsSortBySeverityTest.php b/tests/ResultsSortBySeverityTest.php index baa3c7ede..7632bfc9a 100644 --- a/tests/ResultsSortBySeverityTest.php +++ b/tests/ResultsSortBySeverityTest.php @@ -163,7 +163,7 @@ public function testSortingNotConfigured() { ); // Not configured to sort, should remain unchanged - $this->assertEquals( + $this->assertSame( $this->results_before, $this->results ); @@ -185,7 +185,7 @@ public function testSortingCorrect1() { vipgoci_unittests_output_unsuppress(); // Configured to sort, should be changed - $this->assertEquals( + $this->assertSame( array( 'issues' => array( 24 => array( From 362bdd892279b13e0e0c3e932aff9e7f9f2aae10 Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Fri, 7 May 2021 12:05:36 +0000 Subject: [PATCH 14/25] Replace assertEquals() with assertSame() --- tests/A00IrcApiAlertQueueTest.php | 2 +- tests/A00StatsCountersTest.php | 12 +++--- tests/A09GitHubLabelsTest.php | 6 +-- tests/A09LintLintScanCommitTest.php | 8 ++-- tests/AllUnitTestsInplaceTest.php | 2 +- tests/ApHashesApiScanCommitTest.php | 2 +- tests/ApNonfunctionalChangesTest.php | 2 +- tests/GitHubFetchCommitInfoTest.php | 4 +- tests/GitHubLabelsFetchTest.php | 4 +- tests/GitHubOauth1HeadersGetTest.php | 8 ++-- tests/GitHubOauthSignatureGetHmacSha1Test.php | 2 +- tests/GitHubOrgTeamsTest.php | 8 ++-- tests/GitHubPrGenericCommentsGetTest.php | 6 +-- tests/GitHubPrGenericSupportCommentTest.php | 38 +++++++++---------- tests/GitHubPrReviewEventsGetTest.php | 10 ++--- tests/GitHubPrReviewsCommentsGetByPrTest.php | 10 ++--- tests/GitHubPrReviewsCommentsGetTest.php | 12 +++--- tests/GitHubPrReviewsGetTest.php | 8 ++-- tests/GitHubPrsCommitsListTest.php | 2 +- tests/GitHubPrsImplicatedTest.php | 34 ++++++++--------- tests/GitHubTeamMembersTest.php | 4 +- tests/GitRepoBranchGetTest.php | 2 +- tests/GitRepoRepoFetchCommittedFileTest.php | 2 +- tests/GitRepoRepoFetchTreeTest.php | 4 +- tests/GitRepoRepoGetFileAtCommitTest.php | 8 ++-- tests/GitRepoRepoGetHeadTest.php | 2 +- tests/GitRepoSubmoduleFilePathGetTest.php | 8 ++-- tests/GitRepoSubmoduleGetUrlTest.php | 6 +-- tests/GitRepoSubmodulesListTest.php | 2 +- tests/LintLintDoScanTest.php | 4 +- tests/LintLintGetIssuesTest.php | 4 +- tests/MiscApprovedFilesCommentsRemoveTest.php | 2 +- tests/MiscBlameFilterCommentsTest.php | 2 +- tests/MiscCacheTest.php | 8 ++-- tests/MiscConvertStringToTypeTest.php | 8 ++-- tests/MiscFileExtensionTest.php | 6 +-- tests/MiscFindFieldsInArrayTest.php | 2 +- tests/MiscGitHubEmojisTest.php | 4 +- tests/MiscMarkdownCommentAddPagebreakTest.php | 2 +- tests/MiscResultsFilterIgnorableTest.php | 2 +- tests/MiscSanitizeStringTest.php | 4 +- tests/MiscScandirGitRepoTest.php | 4 +- ...OptionsGenericSupportCommentsMatchTest.php | 2 +- ...tionsGenericSupportCommentsProcessTest.php | 10 ++--- tests/OptionsReadRepoFileTest.php | 28 +++++++------- tests/OptionsReadRepoSkipFilesTest.php | 24 ++++++------ tests/OptionsSensitiveCleanTest.php | 6 +-- tests/PhpcsScanDoScanTest.php | 8 ++-- tests/PhpcsScanIssuesFilterDuplicateTest.php | 4 +- .../PhpcsScanIssuesFilterIrrellevantTest.php | 2 +- ...hpcsScanPossiblyUseNewStandardFileTest.php | 2 +- tests/PhpcsScanScanCommitTest.php | 28 +++++++------- tests/PhpcsScanSingleFileTest.php | 2 +- tests/PhpcsScanWriteXmlStandardFileTest.php | 2 +- tests/StatsRunTimeMeasureTest.php | 8 ++-- tests/StatsStatsInitTest.php | 2 +- .../SupportLevelLabelMetaApiDataFetchTest.php | 4 +- ...portLevelLabelRepoMetaApiDataMatchTest.php | 16 ++++---- tests/SupportLevelLabelSetTest.php | 4 +- tests/SvgScanLookForSpecificTokensTest.php | 2 +- tests/SvgScanWithScannerTest.php | 4 +- tests/VipgociExitStatusTest.php | 4 +- tests/VipgociOptionsBoolHandleTest.php | 6 +-- tests/VipgociOptionsFileHandleTest.php | 2 +- tests/VipgociOptionsIntegerHandleTest.php | 2 +- tests/VipgociOptionsPhpcsRuntimeSetTest.php | 2 +- tests/VipgociOptionsReadEnvTest.php | 18 ++++----- 67 files changed, 231 insertions(+), 231 deletions(-) diff --git a/tests/A00IrcApiAlertQueueTest.php b/tests/A00IrcApiAlertQueueTest.php index fd1a1907b..707aaaed7 100644 --- a/tests/A00IrcApiAlertQueueTest.php +++ b/tests/A00IrcApiAlertQueueTest.php @@ -22,7 +22,7 @@ public function testIrcQueue1() { true ); - $this->assertEquals( + $this->assertSame( array( 'mymessage1', 'mymessage2', diff --git a/tests/A00StatsCountersTest.php b/tests/A00StatsCountersTest.php index 7f49d4d39..0406d0b10 100644 --- a/tests/A00StatsCountersTest.php +++ b/tests/A00StatsCountersTest.php @@ -9,7 +9,7 @@ final class A00StatsCountersTest extends TestCase { * @covers ::vipgoci_counter_report */ function testCounterReport1() { - $this->assertEquals( + $this->assertSame( vipgoci_counter_report( 'illegalaction', 'mycounter1', @@ -18,7 +18,7 @@ function testCounterReport1() { false ); - $this->assertEquals( + $this->assertSame( array(), vipgoci_counter_report( VIPGOCI_COUNTERS_DUMP @@ -30,7 +30,7 @@ function testCounterReport1() { * @covers ::vipgoci_counter_report */ function testCounterReport2() { - $this->assertEquals( + $this->assertSame( true, vipgoci_counter_report( VIPGOCI_COUNTERS_DO, @@ -39,7 +39,7 @@ function testCounterReport2() { ) ); - $this->assertEquals( + $this->assertSame( true, vipgoci_counter_report( VIPGOCI_COUNTERS_DO, @@ -48,7 +48,7 @@ function testCounterReport2() { ) ); - $this->assertEquals( + $this->assertSame( array( 'mycounter2' => 101, ), @@ -92,7 +92,7 @@ function testCounterUpdateWithIssuesFound1() { unset( $report['mycounter2'] ); - $this->assertEquals( + $this->assertSame( array( 'github_pr_unique_issue_issues' => 3, ), diff --git a/tests/A09GitHubLabelsTest.php b/tests/A09GitHubLabelsTest.php index 83246e4aa..fd31d7ac9 100644 --- a/tests/A09GitHubLabelsTest.php +++ b/tests/A09GitHubLabelsTest.php @@ -82,12 +82,12 @@ public function testGitHubAddLabel1() { $labels_after = $this->labels_get(); - $this->assertEquals( + $this->assertSame( -1, count( $labels_before ) - count( $labels_after ) ); - $this->assertEquals( + $this->assertSame( 'Label for testing', $labels_after[0]->name ); @@ -123,7 +123,7 @@ public function testGitHubRemoveLabel1() { $labels_after = $this->labels_get(); - $this->assertEquals( + $this->assertSame( 1, count( $labels_before ) - count( $labels_after ) ); diff --git a/tests/A09LintLintScanCommitTest.php b/tests/A09LintLintScanCommitTest.php index 404f3cc62..bac5cbe46 100644 --- a/tests/A09LintLintScanCommitTest.php +++ b/tests/A09LintLintScanCommitTest.php @@ -152,7 +152,7 @@ public function testLintDoScan1() { $issues_submit[ $pr_item->number][0]['issue']['message'] ); - $this->assertEquals( + $this->assertSame( array( $pr_item->number => array( array( @@ -170,7 +170,7 @@ public function testLintDoScan1() { $issues_submit ); - $this->assertEquals( + $this->assertSame( array( $pr_item->number => array( 'error' => 1, @@ -279,7 +279,7 @@ public function testLintDoScan2() { ); - $this->assertEquals( + $this->assertSame( array( $pr_item->number => array( array( @@ -312,7 +312,7 @@ public function testLintDoScan2() { $issues_submit ); - $this->assertEquals( + $this->assertSame( array( $pr_item->number => array( 'error' => 2, diff --git a/tests/AllUnitTestsInplaceTest.php b/tests/AllUnitTestsInplaceTest.php index bc4ac8ae2..cd8bef5e1 100644 --- a/tests/AllUnitTestsInplaceTest.php +++ b/tests/AllUnitTestsInplaceTest.php @@ -58,7 +58,7 @@ function( $file_item ) { /* * We should end with an empty array. */ - $this->assertEquals( + $this->assertSame( 0, count( $files_arr ) ); diff --git a/tests/ApHashesApiScanCommitTest.php b/tests/ApHashesApiScanCommitTest.php index 06f9bf5d2..0d8848156 100644 --- a/tests/ApHashesApiScanCommitTest.php +++ b/tests/ApHashesApiScanCommitTest.php @@ -125,7 +125,7 @@ public function testApHashesApiScanCommitTest1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( array( 'auto-approvable-6.php' => 'autoapprove-hashes-to-hashes', ), diff --git a/tests/ApNonfunctionalChangesTest.php b/tests/ApNonfunctionalChangesTest.php index 3c02fdded..374e5ea49 100644 --- a/tests/ApNonfunctionalChangesTest.php +++ b/tests/ApNonfunctionalChangesTest.php @@ -87,7 +87,7 @@ public function testNonFunctionalChanges1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( array( 'file1.php' => 'autoapprove-nonfunctional-changes', 'file2.php' => 'autoapprove-nonfunctional-changes', diff --git a/tests/GitHubFetchCommitInfoTest.php b/tests/GitHubFetchCommitInfoTest.php index 7cc78b003..4e62adbe4 100644 --- a/tests/GitHubFetchCommitInfoTest.php +++ b/tests/GitHubFetchCommitInfoTest.php @@ -101,7 +101,7 @@ public function testFetchCommitInfo1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( '2533219d08192025f3209a17ddcf9ff21845a08c', $commit_info->sha ); @@ -112,7 +112,7 @@ public function testFetchCommitInfo1() { $commit_info->files[0]->contents_url ); - $this->assertEquals( + $this->assertSame( array( 'sha' => '524acfffa760fd0b8c1de7cf001f8dd348b399d8', 'filename' => 'test1.txt', diff --git a/tests/GitHubLabelsFetchTest.php b/tests/GitHubLabelsFetchTest.php index 0b28aa315..244563991 100644 --- a/tests/GitHubLabelsFetchTest.php +++ b/tests/GitHubLabelsFetchTest.php @@ -72,12 +72,12 @@ public function testLabelsFetch1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( 'enhancement', $labels[0]->name ); - $this->assertEquals( + $this->assertSame( 'a2eeef', $labels[0]->color ); diff --git a/tests/GitHubOauth1HeadersGetTest.php b/tests/GitHubOauth1HeadersGetTest.php index ecd24ee17..ff9df226b 100644 --- a/tests/GitHubOauth1HeadersGetTest.php +++ b/tests/GitHubOauth1HeadersGetTest.php @@ -52,17 +52,17 @@ function( $item) { $actual_result_arr_new[ $item[0] ] = $item[1]; } - $this->assertEquals( + $this->assertSame( '12', $actual_result_arr_new[ 'OAuth oauth_consumer_key' ] ); - $this->assertEquals( + $this->assertSame( '56', $actual_result_arr_new[ 'oauth_token' ] ); - $this->assertEquals( + $this->assertSame( $actual_result_arr_new[ 'oauth_signature_method' ], 'HMAC-SHA1' ); @@ -106,7 +106,7 @@ function( $item) { ) ); - $this->assertEquals( + $this->assertSame( $signature_expected, $actual_result_arr_new['oauth_signature'] ); diff --git a/tests/GitHubOauthSignatureGetHmacSha1Test.php b/tests/GitHubOauthSignatureGetHmacSha1Test.php index 359a62545..7c1528af6 100644 --- a/tests/GitHubOauthSignatureGetHmacSha1Test.php +++ b/tests/GitHubOauthSignatureGetHmacSha1Test.php @@ -25,7 +25,7 @@ public function testOAuthHmacSha1() { $oauth_keys ); - $this->assertEquals( + $this->assertSame( 'wzbKZTPTrm5evZ/0ccfJ03pLTLg=', $hmac_sha1 ); diff --git a/tests/GitHubOrgTeamsTest.php b/tests/GitHubOrgTeamsTest.php index 7e4f6c80b..abf1d5912 100644 --- a/tests/GitHubOrgTeamsTest.php +++ b/tests/GitHubOrgTeamsTest.php @@ -97,7 +97,7 @@ public function testGitHubOrgTeamsNoFiltersNoKeys() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( $teams_res_actual, $teams_res_actual_cached ); @@ -181,7 +181,7 @@ public function testGitHubOrgTeamsWithFilters() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( $teams_res_actual, $teams_res_actual_cached ); @@ -254,7 +254,7 @@ public function testGitHubOrgTeamsWithKeyes() { ) > 0 ); - $this->assertEquals( + $this->assertSame( $teams_res_actual_keys[0], $teams_res_actual[ $teams_res_actual_keys[0] @@ -277,7 +277,7 @@ public function testGitHubOrgTeamsWithKeyes() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( $teams_res_actual, $teams_res_actual_cached ); diff --git a/tests/GitHubPrGenericCommentsGetTest.php b/tests/GitHubPrGenericCommentsGetTest.php index f24acf4c8..79e676e1c 100644 --- a/tests/GitHubPrGenericCommentsGetTest.php +++ b/tests/GitHubPrGenericCommentsGetTest.php @@ -74,17 +74,17 @@ public function testGitHubPrGenericCommentsGet1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( 1, count( array_keys( $pr_comments ) ) ); - $this->assertEquals( + $this->assertSame( 471306810, $pr_comments[0]->id ); - $this->assertEquals( + $this->assertSame( 'Testing of generic comments.', $pr_comments[0]->body ); diff --git a/tests/GitHubPrGenericSupportCommentTest.php b/tests/GitHubPrGenericSupportCommentTest.php index 26ca30407..25d951fb3 100644 --- a/tests/GitHubPrGenericSupportCommentTest.php +++ b/tests/GitHubPrGenericSupportCommentTest.php @@ -318,7 +318,7 @@ public function testPostingNotConfigured() { count( $pr_comments ) === 0 ); - $this->assertEquals( + $this->assertSame( 0, $this->_countSupportCommentsFromUs( $pr_comments @@ -376,7 +376,7 @@ public function testPostingWorksAnyBranch() { count( $pr_comments ) === 0 ); - $this->assertEquals( + $this->assertSame( 0, $this->_countSupportCommentsFromUs( $pr_comments @@ -389,7 +389,7 @@ public function testPostingWorksAnyBranch() { count( $pr_comments ) > 0 ); - $this->assertEquals( + $this->assertSame( 1, $this->_countSupportCommentsFromUs( $pr_comments @@ -423,7 +423,7 @@ public function testPostingWorksAnyBranch() { count( $pr_comments ) === 0 ); - $this->assertEquals( + $this->assertSame( 0, $this->_countSupportCommentsFromUs( $pr_comments @@ -436,7 +436,7 @@ public function testPostingWorksAnyBranch() { count( $pr_comments ) > 0 ); - $this->assertEquals( + $this->assertSame( 1, $this->_countSupportCommentsFromUs( $pr_comments @@ -491,7 +491,7 @@ public function testPostingWorksSpecificBranch() { count( $pr_comments ) === 0 ); - $this->assertEquals( + $this->assertSame( 0, $this->_countSupportCommentsFromUs( $pr_comments @@ -504,7 +504,7 @@ public function testPostingWorksSpecificBranch() { count( $pr_comments ) > 0 ); - $this->assertEquals( + $this->assertSame( 1, $this->_countSupportCommentsFromUs( $pr_comments @@ -538,7 +538,7 @@ public function testPostingWorksSpecificBranch() { count( $pr_comments ) === 0 ); - $this->assertEquals( + $this->assertSame( 0, $this->_countSupportCommentsFromUs( $pr_comments @@ -551,7 +551,7 @@ public function testPostingWorksSpecificBranch() { count( $pr_comments ) > 0 ); - $this->assertEquals( + $this->assertSame( 1, $this->_countSupportCommentsFromUs( $pr_comments @@ -601,7 +601,7 @@ public function testPostingSkippedInvalidBranch() { $pr_item->number ); - $this->assertEquals( + $this->assertSame( 0, $this->_countSupportCommentsFromUs( $pr_comments @@ -629,7 +629,7 @@ public function testPostingSkippedInvalidBranch() { $pr_item->number ); - $this->assertEquals( + $this->assertSame( 0, $this->_countSupportCommentsFromUs( $pr_comments @@ -683,7 +683,7 @@ public function testPostingWorksWithDraftPRs() { count( $pr_comments ) === 0 ); - $this->assertEquals( + $this->assertSame( 0, $this->_countSupportCommentsFromUs( $pr_comments @@ -696,7 +696,7 @@ public function testPostingWorksWithDraftPRs() { count( $pr_comments ) > 0 ); - $this->assertEquals( + $this->assertSame( 1, $this->_countSupportCommentsFromUs( $pr_comments @@ -730,7 +730,7 @@ public function testPostingWorksWithDraftPRs() { count( $pr_comments ) === 0 ); - $this->assertEquals( + $this->assertSame( 0, $this->_countSupportCommentsFromUs( $pr_comments @@ -743,7 +743,7 @@ public function testPostingWorksWithDraftPRs() { count( $pr_comments ) > 0 ); - $this->assertEquals( + $this->assertSame( 1, $this->_countSupportCommentsFromUs( $pr_comments @@ -781,7 +781,7 @@ public function testPostingWorksWithDraftPRs() { count( $pr_comments ) > 0 ); - $this->assertEquals( + $this->assertSame( 1, $this->_countSupportCommentsFromUs( $pr_comments @@ -860,7 +860,7 @@ public function testPostingWorksWithLabels() { count( $pr_comments ) === 0 ); - $this->assertEquals( + $this->assertSame( 0, $this->_countSupportCommentsFromUs( $pr_comments @@ -892,7 +892,7 @@ public function testPostingWorksWithLabels() { count( $pr_comments ) === 0 ); - $this->assertEquals( + $this->assertSame( 0, $this->_countSupportCommentsFromUs( $pr_comments @@ -929,7 +929,7 @@ public function testPostingWorksWithLabels() { count( $pr_comments ) === 0 ); - $this->assertEquals( + $this->assertSame( 0, $this->_countSupportCommentsFromUs( $pr_comments diff --git a/tests/GitHubPrReviewEventsGetTest.php b/tests/GitHubPrReviewEventsGetTest.php index 962667858..8a89e16df 100644 --- a/tests/GitHubPrReviewEventsGetTest.php +++ b/tests/GitHubPrReviewEventsGetTest.php @@ -100,7 +100,7 @@ public function testGitHubPrReviewEventsGet_no_filters() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( $issue_events, $issue_events_cached ); @@ -156,12 +156,12 @@ public function testGitHubPrReviewEventsGet_with_filters() { ); foreach ( $issue_events as $issue_event ) { - $this->assertEquals( + $this->assertSame( $this->options['test-github-pr-reviews-event-get-username'], $issue_event->actor->login ); - $this->assertEquals( + $this->assertSame( 'labeled', $issue_event->event ); @@ -188,7 +188,7 @@ public function testGitHubPrReviewEventsGet_with_filters() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( $issue_events, $issue_events_cached ); @@ -238,7 +238,7 @@ public function testGitHubPrReviewEventsGet_with_review_ids_only() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( $issue_events, $issue_events_cached ); diff --git a/tests/GitHubPrReviewsCommentsGetByPrTest.php b/tests/GitHubPrReviewsCommentsGetByPrTest.php index 84d04beb9..2254b2827 100644 --- a/tests/GitHubPrReviewsCommentsGetByPrTest.php +++ b/tests/GitHubPrReviewsCommentsGetByPrTest.php @@ -71,28 +71,28 @@ public function testGitHubPrReviewsCommentsGetByPr1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( 1, count( $comments_actual ) ); - $this->assertEquals( + $this->assertSame( 264037556, $comments_actual[0]->id ); - $this->assertEquals( + $this->assertSame( 'file1.php', $comments_actual[0]->path ); - $this->assertEquals( + $this->assertSame( 3, $comments_actual[0]->position ); - $this->assertEquals( + $this->assertSame( 'All output should be escaped.', $comments_actual[0]->body ); diff --git a/tests/GitHubPrReviewsCommentsGetTest.php b/tests/GitHubPrReviewsCommentsGetTest.php index 20e54b297..f34db92a8 100644 --- a/tests/GitHubPrReviewsCommentsGetTest.php +++ b/tests/GitHubPrReviewsCommentsGetTest.php @@ -74,32 +74,32 @@ public function testGitHubPrReviewsCommentsGet1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( 1, count( array_keys( $prs_comments ) ) ); - $this->assertEquals( + $this->assertSame( 212601504, $prs_comments['file1.php:3'][0]->pull_request_review_id ); - $this->assertEquals( + $this->assertSame( 264037556, $prs_comments['file1.php:3'][0]->id ); - $this->assertEquals( + $this->assertSame( 'file1.php', $prs_comments['file1.php:3'][0]->path ); - $this->assertEquals( + $this->assertSame( 3, $prs_comments['file1.php:3'][0]->position ); - $this->assertEquals( + $this->assertSame( 'All output should be escaped.', $prs_comments['file1.php:3'][0]->body ); diff --git a/tests/GitHubPrReviewsGetTest.php b/tests/GitHubPrReviewsGetTest.php index 4c210bf14..d489546c3 100644 --- a/tests/GitHubPrReviewsGetTest.php +++ b/tests/GitHubPrReviewsGetTest.php @@ -70,23 +70,23 @@ public function testGitHubPrReviewsGet1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( 1, count( $reviews_actual ) ); - $this->assertEquals( + $this->assertSame( 212601504, $reviews_actual[0]->id ); - $this->assertEquals( + $this->assertSame( 'Test review', $reviews_actual[0]->body ); - $this->assertEquals( + $this->assertSame( 'COMMENTED', $reviews_actual[0]->state ); diff --git a/tests/GitHubPrsCommitsListTest.php b/tests/GitHubPrsCommitsListTest.php index 24645ac48..7e681b343 100644 --- a/tests/GitHubPrsCommitsListTest.php +++ b/tests/GitHubPrsCommitsListTest.php @@ -78,7 +78,7 @@ public function testGitHubPrsCommitsList1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( array( $this->options['commit-test-repo-prs-commits-list-1'] ), diff --git a/tests/GitHubPrsImplicatedTest.php b/tests/GitHubPrsImplicatedTest.php index 2886653cd..203c6cfd8 100644 --- a/tests/GitHubPrsImplicatedTest.php +++ b/tests/GitHubPrsImplicatedTest.php @@ -82,17 +82,17 @@ public function testGitHubPrsImplicatedIncludeDraftPrs() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( 259078544, $prs_implicated[9]->id ); - $this->assertEquals( + $this->assertSame( '80ebd6d65db88e87665b6ff1aa045f68d17ddeb7', $prs_implicated[9]->merge_commit_sha ); - $this->assertEquals( + $this->assertSame( 'open', $prs_implicated[9]->state ); @@ -142,22 +142,22 @@ public function testGitHubPrsImplicatedSkipDraftPrsFalse() { /* * Verify non-draft PR. */ - $this->assertEquals( + $this->assertSame( 'open', $prs_implicated[33]->state ); - $this->assertEquals( + $this->assertSame( 463586588, $prs_implicated[33]->id ); - $this->assertEquals( + $this->assertSame( 'ac10d1f29e64504d7741cd8ca22981c426c26e9a', $prs_implicated[33]->base->sha ); - $this->assertEquals( + $this->assertSame( false, $prs_implicated[33]->draft ); @@ -165,22 +165,22 @@ public function testGitHubPrsImplicatedSkipDraftPrsFalse() { /* * Verify draft PR. */ - $this->assertEquals( + $this->assertSame( 'open', $prs_implicated[34]->state ); - $this->assertEquals( + $this->assertSame( 463587649, $prs_implicated[34]->id ); - $this->assertEquals( + $this->assertSame( '027de6d804e1d40dbe1b13a3ede7cfa758787b85', $prs_implicated[34]->base->sha ); - $this->assertEquals( + $this->assertSame( true, $prs_implicated[34]->draft ); @@ -203,7 +203,7 @@ public function testGitHubPrsImplicatedSkipDraftPrsFalse() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( $prs_implicated, $prs_implicated_2 ); @@ -252,22 +252,22 @@ public function testGitHubPrsImplicatedSkipDraftPrsTrue() { /* * Verify non-draft PR. */ - $this->assertEquals( + $this->assertSame( 'open', $prs_implicated[33]->state ); - $this->assertEquals( + $this->assertSame( 463586588, $prs_implicated[33]->id ); - $this->assertEquals( + $this->assertSame( 'ac10d1f29e64504d7741cd8ca22981c426c26e9a', $prs_implicated[33]->base->sha ); - $this->assertEquals( + $this->assertSame( false, $prs_implicated[33]->draft ); @@ -290,7 +290,7 @@ public function testGitHubPrsImplicatedSkipDraftPrsTrue() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( $prs_implicated, $prs_implicated_2 ); diff --git a/tests/GitHubTeamMembersTest.php b/tests/GitHubTeamMembersTest.php index 0667ecdd3..34b06e6ea 100644 --- a/tests/GitHubTeamMembersTest.php +++ b/tests/GitHubTeamMembersTest.php @@ -94,7 +94,7 @@ public function testTeamMembers_ids_only_false() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( $team_members_res1_actual, $team_members_res1_actual_cached ); @@ -168,7 +168,7 @@ public function testTeamMembers_ids_only_true() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( $team_members_res2_actual, $team_members_res2_actual_cached ); diff --git a/tests/GitRepoBranchGetTest.php b/tests/GitRepoBranchGetTest.php index 3af03ef61..3a67151db 100644 --- a/tests/GitRepoBranchGetTest.php +++ b/tests/GitRepoBranchGetTest.php @@ -82,7 +82,7 @@ public function testBranchGet1() { $this->options['local-git-repo'] ); - $this->assertEquals( + $this->assertSame( $this->options['commit-test-repo-branch'], $ret ); diff --git a/tests/GitRepoRepoFetchCommittedFileTest.php b/tests/GitRepoRepoFetchCommittedFileTest.php index dd6ceec82..e27a6cdc9 100644 --- a/tests/GitRepoRepoFetchCommittedFileTest.php +++ b/tests/GitRepoRepoFetchCommittedFileTest.php @@ -94,7 +94,7 @@ public function testRepoFetchTree1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( 'Test file contents. Some text.' . PHP_EOL, $ret ); diff --git a/tests/GitRepoRepoFetchTreeTest.php b/tests/GitRepoRepoFetchTreeTest.php index e9a571f83..dafe4a27a 100644 --- a/tests/GitRepoRepoFetchTreeTest.php +++ b/tests/GitRepoRepoFetchTreeTest.php @@ -94,7 +94,7 @@ public function testRepoFetchTree1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( array( 'README.md', 'file-1.txt', @@ -148,7 +148,7 @@ public function testRepoFetchTree2() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( array( 'file-1.txt', ), diff --git a/tests/GitRepoRepoGetFileAtCommitTest.php b/tests/GitRepoRepoGetFileAtCommitTest.php index 2c48f28c0..a03620211 100644 --- a/tests/GitRepoRepoGetFileAtCommitTest.php +++ b/tests/GitRepoRepoGetFileAtCommitTest.php @@ -88,7 +88,7 @@ public function testGetFileData1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( '04f338f924cabbe47994043660304e58a5a3f78f', sha1( $file_content ) ); @@ -104,7 +104,7 @@ public function testGetFileData1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( 'c4587f2e42de3ab1ecdf51c993a3135bb1314b68', sha1( $file_content ) ); @@ -125,7 +125,7 @@ public function testGetFileData1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( '04f338f924cabbe47994043660304e58a5a3f78f', sha1( $file_content ) ); @@ -141,7 +141,7 @@ public function testGetFileData1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( 'f8c824b9bc01a5655e77a10a3f2e5fa704a58f9c', sha1( $file_content ) ); diff --git a/tests/GitRepoRepoGetHeadTest.php b/tests/GitRepoRepoGetHeadTest.php index 8874aa11c..ab88d5e77 100644 --- a/tests/GitRepoRepoGetHeadTest.php +++ b/tests/GitRepoRepoGetHeadTest.php @@ -85,7 +85,7 @@ public function testRepoGetHead1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( $this->options['commit-test-repo-get-head-1'], $ret ); diff --git a/tests/GitRepoSubmoduleFilePathGetTest.php b/tests/GitRepoSubmoduleFilePathGetTest.php index 1154bf173..3475bad57 100644 --- a/tests/GitRepoSubmoduleFilePathGetTest.php +++ b/tests/GitRepoSubmoduleFilePathGetTest.php @@ -90,7 +90,7 @@ public function testSubmoduleFilePathGet1() { 'folder1/vip-go-ci-repo/vip-go-ci.php' ); - $this->assertEquals( + $this->assertSame( array( 'commit_id' => 'a0dba40108fe19f028dbd5970022281cc2cabf81', 'submodule_path' => 'folder1/vip-go-ci-repo', @@ -105,7 +105,7 @@ public function testSubmoduleFilePathGet1() { 'vip-go-ci/notexistingfile.php' ); - $this->assertEquals( + $this->assertSame( null, $submodule_file_info ); @@ -116,7 +116,7 @@ public function testSubmoduleFilePathGet1() { 'vip-go-INVALID/vip-go-ci.php' ); - $this->assertEquals( + $this->assertSame( null, $submodule_file_info ); @@ -127,7 +127,7 @@ public function testSubmoduleFilePathGet1() { 'README.md' ); - $this->assertEquals( + $this->assertSame( null, $submodule_file_info ); diff --git a/tests/GitRepoSubmoduleGetUrlTest.php b/tests/GitRepoSubmoduleGetUrlTest.php index e01be0e60..e52591332 100644 --- a/tests/GitRepoSubmoduleGetUrlTest.php +++ b/tests/GitRepoSubmoduleGetUrlTest.php @@ -83,7 +83,7 @@ public function testGetSubmodulesUrl1() { 'folder1/vip-go-ci-repo' ); - $this->assertEquals( + $this->assertSame( 'https://github.com/automattic/vip-go-ci', $ret ); @@ -93,7 +93,7 @@ public function testGetSubmodulesUrl1() { 'folder1/vip-go-ci-INVALID' ); - $this->assertEquals( + $this->assertSame( null, $ret ); @@ -103,7 +103,7 @@ public function testGetSubmodulesUrl1() { 'folder2/vip-go-ci-INVALID' ); - $this->assertEquals( + $this->assertSame( null, $ret ); diff --git a/tests/GitRepoSubmodulesListTest.php b/tests/GitRepoSubmodulesListTest.php index 0abe149e4..32524fdf2 100644 --- a/tests/GitRepoSubmodulesListTest.php +++ b/tests/GitRepoSubmodulesListTest.php @@ -89,7 +89,7 @@ public function testSubmodulesListGet1() { $this->options['local-git-repo'] ); - $this->assertEquals( + $this->assertSame( array( array( 'commit_id' => 'a0dba40108fe19f028dbd5970022281cc2cabf81', diff --git a/tests/LintLintDoScanTest.php b/tests/LintLintDoScanTest.php index ba98dcba3..0cefe0c95 100644 --- a/tests/LintLintDoScanTest.php +++ b/tests/LintLintDoScanTest.php @@ -54,7 +54,7 @@ public function testLintDoScan1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( array( 'No syntax errors detected in ' . $php_file_path ), @@ -101,7 +101,7 @@ public function testLintDoScan2() { $ret[0] ); - $this->assertEquals( + $this->assertSame( array( "PHP Parse error: syntax error, unexpected end of file, expecting ',' or ';' in " . $php_file_path . " on line 3", 'Errors parsing ' . $php_file_path diff --git a/tests/LintLintGetIssuesTest.php b/tests/LintLintGetIssuesTest.php index 4fde45590..6940511de 100644 --- a/tests/LintLintGetIssuesTest.php +++ b/tests/LintLintGetIssuesTest.php @@ -60,7 +60,7 @@ public function testLintGetIssues1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( array( ), $lint_issues_parsed @@ -113,7 +113,7 @@ public function testLintDoScan2() { $lint_issues_parsed[3][0]['message'] ); - $this->assertEquals( + $this->assertSame( array( 3 => array( array( diff --git a/tests/MiscApprovedFilesCommentsRemoveTest.php b/tests/MiscApprovedFilesCommentsRemoveTest.php index 85576e919..da4ec42fe 100644 --- a/tests/MiscApprovedFilesCommentsRemoveTest.php +++ b/tests/MiscApprovedFilesCommentsRemoveTest.php @@ -34,7 +34,7 @@ public function testRemoveCommentFromResults() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( $results_desired, json_encode( $results_altered ) ); diff --git a/tests/MiscBlameFilterCommentsTest.php b/tests/MiscBlameFilterCommentsTest.php index 705e65de4..98599ce43 100644 --- a/tests/MiscBlameFilterCommentsTest.php +++ b/tests/MiscBlameFilterCommentsTest.php @@ -24,7 +24,7 @@ public function testBlameFilterComments1() { $relevant_commit_ids ); - $this->assertEquals( + $this->assertSame( json_decode( '[{"commit_id":"0131c2739c1a5d2d03bb2645e1be491a6a182091","file_name":"bla-10.php","line_no":1},{"commit_id":"0131c2739c1a5d2d03bb2645e1be491a6a182091","file_name":"bla-10.php","line_no":2},{"commit_id":"0131c2739c1a5d2d03bb2645e1be491a6a182091","file_name":"bla-10.php","line_no":3},{"commit_id":"0131c2739c1a5d2d03bb2645e1be491a6a182091","file_name":"bla-10.php","line_no":4},{"commit_id":"b591cee061d15b1e0187baf9f13a6ab32661bc1b","file_name":"bla-10.php","line_no":5},{"commit_id":"aec27de5f13a5495577ca7ba27fc8b10a04ac89f","file_name":"bla-10.php","line_no":6},{"commit_id":"aec27de5f13a5495577ca7ba27fc8b10a04ac89f","file_name":"bla-10.php","line_no":7}]', true diff --git a/tests/MiscCacheTest.php b/tests/MiscCacheTest.php index beca60c4d..8a64bbb34 100644 --- a/tests/MiscCacheTest.php +++ b/tests/MiscCacheTest.php @@ -45,12 +45,12 @@ public function testCache1() { $cache_id2 ); - $this->assertEquals( + $this->assertSame( $r1, $r1_retrieved ); - $this->assertEquals( + $this->assertSame( $r2, $r2_retrieved ); @@ -98,7 +98,7 @@ public function testCache2() { $cache_id ); - $this->assertEquals( + $this->assertSame( 'mytext', $cached_data ); @@ -115,7 +115,7 @@ public function testCache2() { $cache_id ); - $this->assertEquals( + $this->assertSame( false, $cached_data ); diff --git a/tests/MiscConvertStringToTypeTest.php b/tests/MiscConvertStringToTypeTest.php index 5496db98b..15032c5ec 100644 --- a/tests/MiscConvertStringToTypeTest.php +++ b/tests/MiscConvertStringToTypeTest.php @@ -9,22 +9,22 @@ final class MiscConvertStringToTypeTest extends TestCase { * @covers ::vipgoci_convert_string_to_type */ public function testConvert1() { - $this->assertEquals( + $this->assertSame( true, vipgoci_convert_string_to_type('true') ); - $this->assertEquals( + $this->assertSame( false, vipgoci_convert_string_to_type('false') ); - $this->assertEquals( + $this->assertSame( null, vipgoci_convert_string_to_type('null') ); - $this->assertEquals( + $this->assertSame( 'somestring', vipgoci_convert_string_to_type('somestring') ); diff --git a/tests/MiscFileExtensionTest.php b/tests/MiscFileExtensionTest.php index 1f1e81a72..47f262f3e 100644 --- a/tests/MiscFileExtensionTest.php +++ b/tests/MiscFileExtensionTest.php @@ -15,7 +15,7 @@ public function testFileExtension1() { $file_name ); - $this->assertEquals( + $this->assertSame( 'exe', $file_extension ); @@ -31,7 +31,7 @@ public function testFileExtension2() { $file_name ); - $this->assertEquals( + $this->assertSame( 'exe', $file_extension ); @@ -47,7 +47,7 @@ public function testFileExtension3() { $file_name ); - $this->assertEquals( + $this->assertSame( null, $file_extension ); diff --git a/tests/MiscFindFieldsInArrayTest.php b/tests/MiscFindFieldsInArrayTest.php index 2e1e46c39..7702573e2 100644 --- a/tests/MiscFindFieldsInArrayTest.php +++ b/tests/MiscFindFieldsInArrayTest.php @@ -9,7 +9,7 @@ final class MiscFindFieldsInArrayTest extends TestCase { * @covers ::vipgoci_find_fields_in_array */ public function testFindFields1() { - $this->assertEquals( + $this->assertSame( array( 0 => false, 1 => true, diff --git a/tests/MiscGitHubEmojisTest.php b/tests/MiscGitHubEmojisTest.php index 21da165c4..0bdce9822 100644 --- a/tests/MiscGitHubEmojisTest.php +++ b/tests/MiscGitHubEmojisTest.php @@ -9,14 +9,14 @@ final class MiscGitHubEmojisTest extends TestCase { * @covers ::vipgoci_github_transform_to_emojis */ public function testGitHubEmojis1() { - $this->assertEquals( + $this->assertSame( '', vipgoci_github_transform_to_emojis( 'exclamation' ) ); - $this->assertEquals( + $this->assertSame( ':warning:', vipgoci_github_transform_to_emojis( 'warning' diff --git a/tests/MiscMarkdownCommentAddPagebreakTest.php b/tests/MiscMarkdownCommentAddPagebreakTest.php index cbe2eae47..d09aa738c 100644 --- a/tests/MiscMarkdownCommentAddPagebreakTest.php +++ b/tests/MiscMarkdownCommentAddPagebreakTest.php @@ -16,7 +16,7 @@ public function testPageBreak1() { '***' ); - $this->assertEquals( + $this->assertSame( 'Here is my text. ' . "\n\r" . '***' . "\n\r", $mycomment ); diff --git a/tests/MiscResultsFilterIgnorableTest.php b/tests/MiscResultsFilterIgnorableTest.php index 933b7f818..48a213640 100644 --- a/tests/MiscResultsFilterIgnorableTest.php +++ b/tests/MiscResultsFilterIgnorableTest.php @@ -39,7 +39,7 @@ public function testFilterIgnorable1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( $results_desired, json_encode( $results_altered diff --git a/tests/MiscSanitizeStringTest.php b/tests/MiscSanitizeStringTest.php index 1db639a2c..2db0dbed5 100644 --- a/tests/MiscSanitizeStringTest.php +++ b/tests/MiscSanitizeStringTest.php @@ -9,14 +9,14 @@ final class MiscSanitizeStringTest extends TestCase { * @covers ::vipgoci_sanitize_string */ public function testSanitizeString1() { - $this->assertEquals( + $this->assertSame( 'foobar', vipgoci_sanitize_string( 'FooBar' ) ); - $this->assertEquals( + $this->assertSame( 'foobar', vipgoci_sanitize_string( ' FooBar ' diff --git a/tests/MiscScandirGitRepoTest.php b/tests/MiscScandirGitRepoTest.php index c495666ce..8922edce3 100644 --- a/tests/MiscScandirGitRepoTest.php +++ b/tests/MiscScandirGitRepoTest.php @@ -96,7 +96,7 @@ public function testScandirRepoTest1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( array( 'README.md', 'myfile1.txt', @@ -150,7 +150,7 @@ public function testScandirRepoTest2() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( array( 'README.md' ), diff --git a/tests/OptionsGenericSupportCommentsMatchTest.php b/tests/OptionsGenericSupportCommentsMatchTest.php index 96c5e2a7a..27aeaa5cd 100644 --- a/tests/OptionsGenericSupportCommentsMatchTest.php +++ b/tests/OptionsGenericSupportCommentsMatchTest.php @@ -25,7 +25,7 @@ public function testOptionGenericSupportCommentsMatch () { 'myoption1' ); - $this->assertEquals( + $this->assertSame( array( '1' => array( 'key1' => array( 'value1' ), diff --git a/tests/OptionsGenericSupportCommentsProcessTest.php b/tests/OptionsGenericSupportCommentsProcessTest.php index 681dccb33..a10ac2bb0 100644 --- a/tests/OptionsGenericSupportCommentsProcessTest.php +++ b/tests/OptionsGenericSupportCommentsProcessTest.php @@ -26,7 +26,7 @@ public function testOptionGenericSupportCommentProcessBoolean() { 'boolean' ); - $this->assertEquals( + $this->assertSame( array( 1 => false, 5 => true, @@ -51,7 +51,7 @@ public function testOptionGenericSupportCommentProcessStringStringNotLower() { false ); - $this->assertEquals( + $this->assertSame( array( 3 => 'bar', 6 => 'foo', @@ -78,7 +78,7 @@ public function testOptionGenericSupportCommentProcessStringStringLower() { true ); - $this->assertEquals( + $this->assertSame( array( 3 => 'bar', 6 => 'foo', @@ -105,7 +105,7 @@ public function testOptionGenericSupportCommentProcessArrayNotLower() { false ); - $this->assertEquals( + $this->assertSame( array( 3 => array( 'foo', 'bar', 'test' @@ -143,7 +143,7 @@ public function testOptionGenericSupportCommentProcessArrayLower() { true ); - $this->assertEquals( + $this->assertSame( array( 3 => array( 'foo', 'bar', 'test' diff --git a/tests/OptionsReadRepoFileTest.php b/tests/OptionsReadRepoFileTest.php index ef166373f..9824642c7 100644 --- a/tests/OptionsReadRepoFileTest.php +++ b/tests/OptionsReadRepoFileTest.php @@ -121,7 +121,7 @@ public function testOptionsReadRepoFileIntTest1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( -100, // Should remain unchanged, no option file exists. $this->options['phpcs-severity'] ); @@ -169,7 +169,7 @@ public function testOptionsReadRepoFileIntTest2() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( 1, // Options file should change this to 1 $this->options['phpcs-severity'] ); @@ -220,7 +220,7 @@ public function testOptionsReadRepoFileIntTest3() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( -100, // Should remain unchanged, feature is turned off. $this->options['phpcs-severity'] ); @@ -274,7 +274,7 @@ public function testOptionsReadRepoFileIntTest4() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( -100, // Should remain unchanged, as checks failed $this->options['phpcs-severity'] ); @@ -322,7 +322,7 @@ public function testOptionsReadRepoFileIntTest5() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( -100, // Should remain unchanged $this->options['phpcs-severity'] ); @@ -371,7 +371,7 @@ public function testOptionsReadRepoFileIntTest6() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( -100, // Should remain unchanged $this->options['phpcs-severity'] ); @@ -420,7 +420,7 @@ public function testOptionsReadRepoFileBoolTest1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( false, // Should remain unchanged $this->options['post-generic-pr-support-comments'] ); @@ -471,7 +471,7 @@ public function testOptionsReadRepoFileBoolTest2() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( false, // Should not have changed $this->options['post-generic-pr-support-comments'] ); @@ -521,7 +521,7 @@ public function testOptionsReadRepoFileBoolTest3() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( true, // Should have changed, repo setting is true $this->options['post-generic-pr-support-comments'] ); @@ -573,7 +573,7 @@ public function testOptionsReadRepoFileArrayTest1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( array( 'MySniff1', 'MySniff2', @@ -630,7 +630,7 @@ public function testOptionsReadRepoFileArrayTest2() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( array( 'OtherSniff1', 'OtherSniff2', @@ -694,17 +694,17 @@ public function testOptionsReadRepoFileOptionAllowedTest1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( true, // Should have changed, repo setting is true $this->options['post-generic-pr-support-comments'] ); - $this->assertEquals( + $this->assertSame( -100, // Should not have changed, repo setting is set, but cannot be set $this->options['phpcs-severity'] ); - $this->assertEquals( + $this->assertSame( array( 'MySniff.MySniffName' ), // Should not have changed, is not configured $this->options['phpcs-sniffs-exclude'] ); diff --git a/tests/OptionsReadRepoSkipFilesTest.php b/tests/OptionsReadRepoSkipFilesTest.php index abceb3bc6..97df78963 100644 --- a/tests/OptionsReadRepoSkipFilesTest.php +++ b/tests/OptionsReadRepoSkipFilesTest.php @@ -87,14 +87,14 @@ public function testOptionsReadRepoFilePhpcsTest1() { $this->options ); - $this->assertEquals( + $this->assertSame( array( 'qqq-75x-n/plugins', ), $this->options['phpcs-skip-folders'] ); - $this->assertEquals( + $this->assertSame( array( 'mmm-300/800', ), @@ -120,14 +120,14 @@ public function testOptionsReadRepoFilePhpcsTest2() { $this->options ); - $this->assertEquals( + $this->assertSame( array( 'qqq-75x-n/plugins', ), $this->options['phpcs-skip-folders'] ); - $this->assertEquals( + $this->assertSame( array( 'mmm-300/800', ), @@ -153,7 +153,7 @@ public function testOptionsReadRepoFilePhpcsTest3() { $this->options ); - $this->assertEquals( + $this->assertSame( array( 'qqq-75x-n/plugins', 'bar-34/751-508x', @@ -164,7 +164,7 @@ public function testOptionsReadRepoFilePhpcsTest3() { $this->options['phpcs-skip-folders'] ); - $this->assertEquals( + $this->assertSame( array( 'mmm-300/800', ), @@ -188,14 +188,14 @@ public function testOptionsReadRepoFileLintTest1() { $this->options ); - $this->assertEquals( + $this->assertSame( array( 'qqq-75x-n/plugins', ), $this->options['phpcs-skip-folders'] ); - $this->assertEquals( + $this->assertSame( array( 'mmm-300/800', ), @@ -221,14 +221,14 @@ public function testOptionsReadRepoFileLintTest2() { $this->options ); - $this->assertEquals( + $this->assertSame( array( 'qqq-75x-n/plugins', ), $this->options['phpcs-skip-folders'] ); - $this->assertEquals( + $this->assertSame( array( 'mmm-300/800', ), @@ -254,14 +254,14 @@ public function testOptionsReadRepoFileLintTest3() { $this->options ); - $this->assertEquals( + $this->assertSame( array( 'qqq-75x-n/plugins', ), $this->options['phpcs-skip-folders'] ); - $this->assertEquals( + $this->assertSame( array( 'mmm-300/800', 'foo-bar-1/750-500x', diff --git a/tests/OptionsSensitiveCleanTest.php b/tests/OptionsSensitiveCleanTest.php index da7cbe93e..b2f57b3e6 100644 --- a/tests/OptionsSensitiveCleanTest.php +++ b/tests/OptionsSensitiveCleanTest.php @@ -27,7 +27,7 @@ public function testSensitiveClean1 () { * cleaning, should remain unchanged. */ - $this->assertEquals( + $this->assertSame( $options, $options_clean ); @@ -49,7 +49,7 @@ public function testSensitiveClean1 () { $options ); - $this->assertEquals( + $this->assertSame( array( 'a1' => '***', 'b1' => 'notsecret', @@ -77,7 +77,7 @@ public function testSensitiveClean1 () { $options ); - $this->assertEquals( + $this->assertSame( array( 'a1' => '***', 'b1' => 'notsecret', diff --git a/tests/PhpcsScanDoScanTest.php b/tests/PhpcsScanDoScanTest.php index 1bd90f03c..c74fa2fa7 100644 --- a/tests/PhpcsScanDoScanTest.php +++ b/tests/PhpcsScanDoScanTest.php @@ -91,7 +91,7 @@ public function testDoScanTest1() { unlink( $temp_file_path ); - $this->assertEquals( + $this->assertSame( '{"totals":{"errors":1,"warnings":1,"fixable":0},"files":{"' . addcslashes( $temp_file_path, '/' ) . '":{"errors":1,"warnings":1,"messages":[{"message":"All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found \'time\'.","source":"WordPress.Security.EscapeOutput.OutputNotEscaped","severity":5,"fixable":false,"type":"ERROR","line":2,"column":6},{"message":"`strip_tags()` does not strip CSS and JS in between the script and style tags. Use `wp_strip_all_tags()` to strip all tags.","source":"WordPressVIPMinimum.Functions.StripTags.StripTagsOneParameter","severity":5,"fixable":false,"type":"WARNING","line":4,"column":16}]}}}', $phpcs_res ); @@ -181,7 +181,7 @@ public function testDoScanTest2() { unlink( $temp_file_path ); - $this->assertEquals( + $this->assertSame( '{"totals":{"errors":2,"warnings":1,"fixable":1},"files":{"' . addcslashes( $temp_file_path, '/' ) . '":{"errors":2,"warnings":1,"messages":[{"message":"All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found \'time\'.","source":"WordPress.Security.EscapeOutput.OutputNotEscaped","severity":5,"fixable":false,"type":"ERROR","line":2,"column":6},{"message":"`strip_tags()` does not strip CSS and JS in between the script and style tags. Use `wp_strip_all_tags()` to strip all tags.","source":"WordPressVIPMinimum.Functions.StripTags.StripTagsOneParameter","severity":5,"fixable":false,"type":"WARNING","line":4,"column":16},{"message":"Expected 1 space before array closer, found 5.","source":"WordPress.Arrays.ArrayDeclarationSpacing.SpaceBeforeArrayCloser","severity":5,"fixable":true,"type":"ERROR","line":5,"column":25}]}}}', $phpcs_res ); @@ -236,7 +236,7 @@ public function testDoScanTest3() { unlink( $temp_file_path ); - $this->assertEquals( + $this->assertSame( '{"totals":{"errors":1,"warnings":0,"fixable":0},"files":{"' . addcslashes( $temp_file_path, '/' ) . '":{"errors":1,"warnings":0,"messages":[{"message":"All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found \'time\'.","source":"WordPress.Security.EscapeOutput.OutputNotEscaped","severity":5,"fixable":false,"type":"ERROR","line":2,"column":6}]}}}', $phpcs_res ); @@ -310,7 +310,7 @@ public function testDoScanTest4() { unlink( $temp_file_path ); - $this->assertEquals( + $this->assertSame( '{"totals":{"errors":2,"warnings":0,"fixable":1},"files":{"' . addcslashes( $temp_file_path, '/' ) . '":{"errors":2,"warnings":0,"messages":[{"message":"All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found \'time\'.","source":"WordPress.Security.EscapeOutput.OutputNotEscaped","severity":5,"fixable":false,"type":"ERROR","line":2,"column":6},{"message":"Expected 1 space before array closer, found 5.","source":"WordPress.Arrays.ArrayDeclarationSpacing.SpaceBeforeArrayCloser","severity":5,"fixable":true,"type":"ERROR","line":5,"column":25}]}}}', $phpcs_res ); diff --git a/tests/PhpcsScanIssuesFilterDuplicateTest.php b/tests/PhpcsScanIssuesFilterDuplicateTest.php index 22d6202e9..c3ea5ea1a 100644 --- a/tests/PhpcsScanIssuesFilterDuplicateTest.php +++ b/tests/PhpcsScanIssuesFilterDuplicateTest.php @@ -46,7 +46,7 @@ public function testFilterDuplicate1() { ) ); - $this->assertEquals( + $this->assertSame( array( array( 'message' => 'json_encode() is discouraged. Use wp_json_encode() instead.', @@ -117,7 +117,7 @@ public function testFilterDuplicate2() { ) ); - $this->assertEquals( + $this->assertSame( array( array( 'message' => 'json_encode() is discouraged. Use wp_json_encode() instead.', diff --git a/tests/PhpcsScanIssuesFilterIrrellevantTest.php b/tests/PhpcsScanIssuesFilterIrrellevantTest.php index 57a9c5551..f8ac3c80f 100644 --- a/tests/PhpcsScanIssuesFilterIrrellevantTest.php +++ b/tests/PhpcsScanIssuesFilterIrrellevantTest.php @@ -38,7 +38,7 @@ public function testDoScanIssuesFilter1() { $file_relative_lines ); - $this->assertEquals( + $this->assertSame( array( array( 'message' => 'json_encode() is discouraged. Use wp_json_encode() instead.', diff --git a/tests/PhpcsScanPossiblyUseNewStandardFileTest.php b/tests/PhpcsScanPossiblyUseNewStandardFileTest.php index fe8cce7fc..7cf8f6f89 100644 --- a/tests/PhpcsScanPossiblyUseNewStandardFileTest.php +++ b/tests/PhpcsScanPossiblyUseNewStandardFileTest.php @@ -46,7 +46,7 @@ public function testDoNotUseNewstandardFileTest() { $this->options['phpcs-standard-file'] ); - $this->assertEquals( + $this->assertSame( $this->original_standard, $this->options['phpcs-standard'] ); diff --git a/tests/PhpcsScanScanCommitTest.php b/tests/PhpcsScanScanCommitTest.php index 25dcda872..f1a0d21ea 100644 --- a/tests/PhpcsScanScanCommitTest.php +++ b/tests/PhpcsScanScanCommitTest.php @@ -138,7 +138,7 @@ public function testDoScanTest1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( array( 8 => array( array( @@ -194,7 +194,7 @@ public function testDoScanTest1() { $issues_submit ); - $this->assertEquals( + $this->assertSame( array( 8 => array( 'error' => 3, @@ -258,13 +258,13 @@ public function testDoScanTest2() { * we should have initialised statistics * for both. Make sure it is so. */ - $this->assertEquals( + $this->assertSame( array( - 21 => array( + 22 => array( 'error' => 0, ), - 22 => array( + 21 => array( 'error' => 0, ), ), @@ -295,7 +295,7 @@ public function testDoScanTest2() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( array( 21 => array( array( @@ -340,7 +340,7 @@ public function testDoScanTest2() { $issues_submit ); - $this->assertEquals( + $this->assertSame( array( 21 => array( 'error' => 2, @@ -435,7 +435,7 @@ public function testDoScanTest3() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( array( 30 => array( array( @@ -512,7 +512,7 @@ public function testDoScanTest3() { $issues_submit ); - $this->assertEquals( + $this->assertSame( array( 30 => array( 'error' => 3, @@ -614,7 +614,7 @@ public function testDoScanTest4() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( array( 30 => array( /* @@ -642,11 +642,11 @@ public function testDoScanTest4() { $issues_submit ); - $this->assertEquals( + $this->assertSame( array( 30 => array( - 'error' => 0, 'warning' => 1, + 'error' => 0, ) ), $issues_stats @@ -794,7 +794,7 @@ public function testDoScanTest5() { $tmp_standard_dir ); - $this->assertEquals( + $this->assertSame( array( 30 => array( array( @@ -882,7 +882,7 @@ public function testDoScanTest5() { $issues_submit ); - $this->assertEquals( + $this->assertSame( array( 30 => array( 'error' => 4, diff --git a/tests/PhpcsScanSingleFileTest.php b/tests/PhpcsScanSingleFileTest.php index f5d4df889..9a39b5ab5 100644 --- a/tests/PhpcsScanSingleFileTest.php +++ b/tests/PhpcsScanSingleFileTest.php @@ -166,7 +166,7 @@ public function testDoScanTest1() { $expected_results['file_issues_arr_master'] ); - $this->assertEquals( + $this->assertSame( $expected_results, $scan_results ); diff --git a/tests/PhpcsScanWriteXmlStandardFileTest.php b/tests/PhpcsScanWriteXmlStandardFileTest.php index ed89b4a6c..eb8aa0259 100644 --- a/tests/PhpcsScanWriteXmlStandardFileTest.php +++ b/tests/PhpcsScanWriteXmlStandardFileTest.php @@ -48,7 +48,7 @@ public function testWriteXmlStandardFile1() { $xml_content ); - $this->assertEquals( + $this->assertSame( '' . '' . 'Custom coding standard' . diff --git a/tests/StatsRunTimeMeasureTest.php b/tests/StatsRunTimeMeasureTest.php index 0c7e07b1c..99d4b05ec 100644 --- a/tests/StatsRunTimeMeasureTest.php +++ b/tests/StatsRunTimeMeasureTest.php @@ -9,7 +9,7 @@ final class StatsRunTimeMeasureTest extends TestCase { * @covers ::vipgoci_runtime_measure */ function testRuntimeMeasure1() { - return $this->assertEquals( + return $this->assertSame( false, vipgoci_runtime_measure( 'illegalaction', 'mytimer1' ) ); @@ -19,7 +19,7 @@ function testRuntimeMeasure1() { * @covers ::vipgoci_runtime_measure */ function testRuntimeMeasure2() { - return $this->assertEquals( + return $this->assertSame( false, vipgoci_runtime_measure( VIPGOCI_RUNTIME_STOP, 'mytimer2' ) ); @@ -29,7 +29,7 @@ function testRuntimeMeasure2() { * @covers ::vipgoci_runtime_measure */ function testRuntimeMeasure3() { - $this->assertEquals( + $this->assertSame( true, vipgoci_runtime_measure( VIPGOCI_RUNTIME_START, 'mytimer3' ) ); @@ -55,7 +55,7 @@ function testRuntimeMeasure3() { * @covers ::vipgoci_runtime_measure */ function testRuntimeMeasure4() { - $this->assertEquals( + $this->assertSame( true, vipgoci_runtime_measure( VIPGOCI_RUNTIME_START, 'mytimer4' ) ); diff --git a/tests/StatsStatsInitTest.php b/tests/StatsStatsInitTest.php index 227fae2b8..2600216ac 100644 --- a/tests/StatsStatsInitTest.php +++ b/tests/StatsStatsInitTest.php @@ -30,7 +30,7 @@ public function testStatsInit() { $stats_arr ); - return $this->assertEquals( + return $this->assertSame( array( 'issues' => array( 100 => diff --git a/tests/SupportLevelLabelMetaApiDataFetchTest.php b/tests/SupportLevelLabelMetaApiDataFetchTest.php index 4a89bc1f8..89b68cd98 100644 --- a/tests/SupportLevelLabelMetaApiDataFetchTest.php +++ b/tests/SupportLevelLabelMetaApiDataFetchTest.php @@ -68,7 +68,7 @@ public function testMetaApiDataFetch() { ) ) ); - $this->assertEquals( + $this->assertSame( $this->options['support-level'], $repo_meta_data['data'][0][ $this->options['support-level-field-name'] @@ -86,7 +86,7 @@ public function testMetaApiDataFetch() { $this->options['repo-name'] ); - $this->assertEquals( + $this->assertSame( $repo_meta_data, $repo_meta_data_2 ); diff --git a/tests/SupportLevelLabelRepoMetaApiDataMatchTest.php b/tests/SupportLevelLabelRepoMetaApiDataMatchTest.php index 86b470866..fb8188090 100644 --- a/tests/SupportLevelLabelRepoMetaApiDataMatchTest.php +++ b/tests/SupportLevelLabelRepoMetaApiDataMatchTest.php @@ -81,7 +81,7 @@ public function test_repo_meta_api_data_match1() { $option_key_no = null; - $this->assertEquals( + $this->assertSame( false, vipgoci_repo_meta_api_data_match( @@ -91,7 +91,7 @@ public function test_repo_meta_api_data_match1() { ) ); - $this->assertEquals( + $this->assertSame( null, $option_key_no ); @@ -113,7 +113,7 @@ public function test_repo_meta_api_data_match2() { $option_key_no = null; - $this->assertEquals( + $this->assertSame( false, vipgoci_repo_meta_api_data_match( @@ -123,7 +123,7 @@ public function test_repo_meta_api_data_match2() { ) ); - $this->assertEquals( + $this->assertSame( null, $option_key_no ); @@ -145,7 +145,7 @@ public function test_repo_meta_api_data_match3() { $option_key_no = null; - $this->assertEquals( + $this->assertSame( false, vipgoci_repo_meta_api_data_match( @@ -155,7 +155,7 @@ public function test_repo_meta_api_data_match3() { ) ); - $this->assertEquals( + $this->assertSame( null, $option_key_no ); @@ -177,7 +177,7 @@ public function test_repo_meta_api_data_match4() { $option_key_no = null; - $this->assertEquals( + $this->assertSame( true, vipgoci_repo_meta_api_data_match( @@ -187,7 +187,7 @@ public function test_repo_meta_api_data_match4() { ) ); - $this->assertEquals( + $this->assertSame( 2, $option_key_no ); diff --git a/tests/SupportLevelLabelSetTest.php b/tests/SupportLevelLabelSetTest.php index 32543bdd7..3dd303e1e 100644 --- a/tests/SupportLevelLabelSetTest.php +++ b/tests/SupportLevelLabelSetTest.php @@ -143,7 +143,7 @@ public function testSupportLevelSet1() { $support_labels_cnt = $this->_findSupportLabelstoPrs(); - $this->assertEquals( + $this->assertSame( 0, $support_labels_cnt ); @@ -182,7 +182,7 @@ public function testSupportLevelSet2() { */ $support_labels_cnt = $this->_findSupportLabelstoPrs(); - $this->assertEquals( + $this->assertSame( 0, $support_labels_cnt ); diff --git a/tests/SvgScanLookForSpecificTokensTest.php b/tests/SvgScanLookForSpecificTokensTest.php index 9adf34807..5fd67f782 100644 --- a/tests/SvgScanLookForSpecificTokensTest.php +++ b/tests/SvgScanLookForSpecificTokensTest.php @@ -59,7 +59,7 @@ public function testSpecificTokens1() { $temp_file_name ); - $this->assertEquals( + $this->assertSame( $results_expected, $results ); diff --git a/tests/SvgScanWithScannerTest.php b/tests/SvgScanWithScannerTest.php index 57ee53534..cf7b7dbab 100644 --- a/tests/SvgScanWithScannerTest.php +++ b/tests/SvgScanWithScannerTest.php @@ -75,7 +75,7 @@ public function testScanner1() { $temp_file_name ); - $this->assertEquals( + $this->assertSame( $scanner_results_expected, $scanner_results ); @@ -136,7 +136,7 @@ public function testScanner2() { $temp_file_name ); - $this->assertEquals( + $this->assertSame( $scanner_results_expected, $scanner_results ); diff --git a/tests/VipgociExitStatusTest.php b/tests/VipgociExitStatusTest.php index 1f11743ff..86472751d 100644 --- a/tests/VipgociExitStatusTest.php +++ b/tests/VipgociExitStatusTest.php @@ -21,7 +21,7 @@ public function testExitStatus1() { ) ); - $this->assertEquals( + $this->assertSame( 0, $exit_status ); @@ -43,7 +43,7 @@ public function testExitStatus2() { ) ); - $this->assertEquals( + $this->assertSame( 250, $exit_status ); diff --git a/tests/VipgociOptionsBoolHandleTest.php b/tests/VipgociOptionsBoolHandleTest.php index 246b33d3d..bcc075f87 100644 --- a/tests/VipgociOptionsBoolHandleTest.php +++ b/tests/VipgociOptionsBoolHandleTest.php @@ -18,7 +18,7 @@ public function testOptionsBoolHandle1() { 'false' ); - $this->assertEquals( + $this->assertSame( false, $options['mytestoption'] ); @@ -37,7 +37,7 @@ public function testOptionsBoolHandle2() { false ); - $this->assertEquals( + $this->assertSame( false, $options['mytestoption'] ); @@ -57,7 +57,7 @@ public function testOptionsBoolHandle3() { true ); - $this->assertEquals( + $this->assertSame( true, $options['mytestoption'] ); diff --git a/tests/VipgociOptionsFileHandleTest.php b/tests/VipgociOptionsFileHandleTest.php index 688e743b9..bd92c6e95 100644 --- a/tests/VipgociOptionsFileHandleTest.php +++ b/tests/VipgociOptionsFileHandleTest.php @@ -24,7 +24,7 @@ public function testOptionsFileHandle1() { $temp_file_name ); - $this->assertEquals( + $this->assertSame( $options['mytestoption'], $temp_file_name ); diff --git a/tests/VipgociOptionsIntegerHandleTest.php b/tests/VipgociOptionsIntegerHandleTest.php index e2fd1d477..9aeffbb34 100644 --- a/tests/VipgociOptionsIntegerHandleTest.php +++ b/tests/VipgociOptionsIntegerHandleTest.php @@ -18,7 +18,7 @@ public function testOptionsIntegerHandle1() { 5 ); - $this->assertEquals( + $this->assertSame( array( 'mytestoption' => 5 ), diff --git a/tests/VipgociOptionsPhpcsRuntimeSetTest.php b/tests/VipgociOptionsPhpcsRuntimeSetTest.php index 5ec8edb87..87b06d6dd 100644 --- a/tests/VipgociOptionsPhpcsRuntimeSetTest.php +++ b/tests/VipgociOptionsPhpcsRuntimeSetTest.php @@ -23,7 +23,7 @@ public function testOptionsPhpcsRuntimeSet1() { 'myphpcsruntimeoption', ); - $this->assertEquals( + $this->assertSame( array( 'myphpcsruntimeoption' => array( array( diff --git a/tests/VipgociOptionsReadEnvTest.php b/tests/VipgociOptionsReadEnvTest.php index 352a93f90..32eca1544 100644 --- a/tests/VipgociOptionsReadEnvTest.php +++ b/tests/VipgociOptionsReadEnvTest.php @@ -63,13 +63,13 @@ public function testOptionsReadEnv1() { /* * Should successfully read from environment. */ - $this->assertEquals( + $this->assertSame( array( - 'repo-owner' => 'repo-test-owner', 'repo-name' => 'repo-test-name', 'env-options' => array( 0 => 'repo-owner=PHP_ROWNER', ), + 'repo-owner' => 'repo-test-owner', ), $options ); @@ -111,7 +111,7 @@ public function testOptionsReadEnv2() { /* * Should not have read from environment. */ - $this->assertEquals( + $this->assertSame( array( 'repo-name' => 'repo-test-name', 'env-options' => array( @@ -159,7 +159,7 @@ public function testOptionsReadEnv3() { /* * Should not have read from environment. */ - $this->assertEquals( + $this->assertSame( array( 'repo-name' => 'repo-test-name', 'env-options' => array( @@ -205,7 +205,7 @@ public function testOptionsReadEnv4() { /* * Should not have read from environment. */ - $this->assertEquals( + $this->assertSame( array( 'repo-name' => 'repo-test-name', 'env-options' => array( @@ -252,7 +252,7 @@ public function testOptionsReadEnv5() { /* * Should not have read from environment. */ - $this->assertEquals( + $this->assertSame( array( 'repo-name' => 'repo-test-name', 'env-options' => array( @@ -299,7 +299,7 @@ public function testOptionsReadEnv6() { /* * Should not have read from environment. */ - $this->assertEquals( + $this->assertSame( array( 'repo-name' => 'repo-test-name', 'env-options' => array( @@ -346,14 +346,14 @@ public function testOptionsReadEnv7() { /* * Should not have read from environment. */ - $this->assertEquals( + $this->assertSame( array( 'repo-name' => 'repo-test-name', - 'repo-owner' => 'repo-test-owner2', 'env-options' => array( 0 => 'repo-owner=PHP_ROWNER', 1 => 'repo-owner=PHP_ROWNER2', ), + 'repo-owner' => 'repo-test-owner2', ), $options ); From ac51b0e9a7bfc5c53d1511b23d63d68410b32225 Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Fri, 7 May 2021 12:15:49 +0000 Subject: [PATCH 15/25] Replace assertEquals() with assertSame(), along with adjustments --- tests/ApAutoApprovalTest.php | 45 +++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/tests/ApAutoApprovalTest.php b/tests/ApAutoApprovalTest.php index d34e20ad7..b1d8dbac0 100644 --- a/tests/ApAutoApprovalTest.php +++ b/tests/ApAutoApprovalTest.php @@ -73,6 +73,9 @@ protected function setUp(): void { $this->options['local-git-repo'] = false; + $this->options['pr-test-ap-auto-approval-1'] = + (int) $this->options['pr-test-ap-auto-approval-1']; + $this->cleanup_prs(); } @@ -232,13 +235,13 @@ public function testAutoApproval1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( 1, count( $prs_implicated ) ); foreach ( $prs_implicated as $pr_item ) { - $this->assertEquals( + $this->assertSame( $this->options['pr-test-ap-auto-approval-1'], $pr_item->number ); @@ -302,7 +305,7 @@ public function testAutoApproval2() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( array(), $results ); @@ -319,13 +322,13 @@ public function testAutoApproval2() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( 1, count( $prs_implicated ) ); foreach ( $prs_implicated as $pr_item ) { - $this->assertEquals( + $this->assertSame( $this->options['pr-test-ap-auto-approval-1'], $pr_item->number ); @@ -346,13 +349,13 @@ public function testAutoApproval2() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( 1, count( $pr_item_reviews ) ); foreach( $pr_item_reviews as $pr_item_review ) { - $this->assertEquals( + $this->assertSame( 'APPROVED', $pr_item_review->state ); @@ -361,7 +364,7 @@ public function testAutoApproval2() { $labels = $this->pr_get_labels(); - $this->assertEquals( + $this->assertSame( $this->options['autoapprove-label'], $labels->name ); @@ -424,7 +427,7 @@ public function testAutoApproval3() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( array(), $results ); @@ -441,13 +444,13 @@ public function testAutoApproval3() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( 1, count( $prs_implicated ) ); foreach ( $prs_implicated as $pr_item ) { - $this->assertEquals( + $this->assertSame( $this->options['pr-test-ap-auto-approval-1'], $pr_item->number ); @@ -468,7 +471,7 @@ public function testAutoApproval3() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( 0, count( $pr_item_reviews ) ); @@ -476,7 +479,7 @@ public function testAutoApproval3() { $label = $this->pr_get_labels(); - $this->assertEquals( + $this->assertSame( false, $label ); @@ -558,13 +561,13 @@ public function testAutoApproval4() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( 1, count( $prs_implicated ) ); foreach ( $prs_implicated as $pr_item ) { - $this->assertEquals( + $this->assertSame( $this->options['pr-test-ap-auto-approval-1'], $pr_item->number ); @@ -585,7 +588,7 @@ public function testAutoApproval4() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( 0, count( $pr_item_reviews ) ); @@ -593,12 +596,12 @@ public function testAutoApproval4() { $label = $this->pr_get_labels(); - $this->assertEquals( + $this->assertSame( false, $label ); - $this->assertEquals( + $this->assertSame( 1, $results['stats'] [ VIPGOCI_STATS_HASHES_API ] @@ -606,7 +609,7 @@ public function testAutoApproval4() { [ 'info' ] ); - $this->assertEquals( + $this->assertSame( 'file-1.php', $results['issues'] [ $this->options['pr-test-ap-auto-approval-1'] ] @@ -672,7 +675,7 @@ public function testAutoApproval5() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( 0, count( $pr_item_reviews ) ); @@ -727,7 +730,7 @@ public function testAutoApproval5() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( 1, count( $pr_item_reviews ) ); From 7090014754c113697661ec4f904830f34894c0f5 Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Fri, 7 May 2021 12:16:19 +0000 Subject: [PATCH 16/25] Replace assertEquals() with assertSame(), along with adjustments --- tests/ApFileTypesTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ApFileTypesTest.php b/tests/ApFileTypesTest.php index 8ab040696..d6e480aba 100644 --- a/tests/ApFileTypesTest.php +++ b/tests/ApFileTypesTest.php @@ -105,12 +105,12 @@ public function testFileTypes1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( array( + 'README.md' => 'autoapprove-filetypes', 'auto-approvable-1.txt' => 'autoapprove-filetypes', 'auto-approvable-2.txt' => 'autoapprove-filetypes', 'auto-approvable-3.jpg' => 'autoapprove-filetypes', - 'README.md' => 'autoapprove-filetypes', ), $auto_approved_files_arr ); From 0127ff5282a8c87fb2622fb88d90bd1488cd45b5 Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Fri, 7 May 2021 12:16:56 +0000 Subject: [PATCH 17/25] Replace assertEquals() with assertSame(), along with adjustments --- tests/ApSvgFilesTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ApSvgFilesTest.php b/tests/ApSvgFilesTest.php index 1ec403ca2..258766015 100644 --- a/tests/ApSvgFilesTest.php +++ b/tests/ApSvgFilesTest.php @@ -127,7 +127,7 @@ public function testApSvgFiles1() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( array( 'auto-approvable-1.svg' => 'ap-svg-files', 'auto-approvable-2.svg' => 'ap-svg-files', @@ -188,13 +188,13 @@ public function testApSvgFiles2() { vipgoci_unittests_output_unsuppress(); - $this->assertEquals( + $this->assertSame( array( 'auto-approvable-1.svg' => 'ap-svg-files', 'auto-approvable-2-renamed.svg' => 'ap-svg-files', + 'auto-approvable-7.svg' => 'ap-svg-files', 'auto-approvable3.svg' => 'ap-svg-files', 'auto-approvable4.svg' => 'ap-svg-files', - 'auto-approvable-7.svg' => 'ap-svg-files', ), $auto_approved_files_arr ); From 0838eac52a82f8498b317f7c99d579f1fae43d79 Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Fri, 7 May 2021 12:17:16 +0000 Subject: [PATCH 18/25] Replace assertEquals() with assertSame(), along with adjustments --- tests/GitHubApiCurlHeadersTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/GitHubApiCurlHeadersTest.php b/tests/GitHubApiCurlHeadersTest.php index c5e1d267a..b1ac93f32 100644 --- a/tests/GitHubApiCurlHeadersTest.php +++ b/tests/GitHubApiCurlHeadersTest.php @@ -46,12 +46,12 @@ public function testCurlHeaders1() { null ); - $this->assertEquals( + $this->assertSame( array( 'content-type' => array( 'text/plain' ), 'date' => array( 'Mon, 04 Mar 2019 16:43:35 GMT' ), 'location' => array( 'https://www.ruv.is/' ), - 'status' => array( 200, 'OK' ), + 'status' => array( '200', 'OK' ), ), $actual_results ); @@ -96,11 +96,11 @@ public function testCurlHeaders2() { null ); - $this->assertEquals( + $this->assertSame( array( + 'status' => array( '205' ), 'date' => array( 'Mon, 04 Mar 2020 16:43:35 GMT' ), 'location' => array( 'https://www.kernel.org/' ), - 'status' => array( 205 ), ), $actual_results ); From 87eab1d3bb9cc63c7aa5015a7a00d9eb3646e6f1 Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Fri, 7 May 2021 12:24:28 +0000 Subject: [PATCH 19/25] Replace assertEquals() with assertSame(), along with adjustments --- tests/MiscTempTest.php | 55 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/tests/MiscTempTest.php b/tests/MiscTempTest.php index de5708bec..10a9db7f0 100644 --- a/tests/MiscTempTest.php +++ b/tests/MiscTempTest.php @@ -34,12 +34,12 @@ public function testTempFile1() { $temp_file_name ); - $this->assertEquals( - $file_name_extension, + $this->assertSame( + '', $temp_file_extension ); - $this->assertEquals( + $this->assertSame( $file_contents, $temp_file_contents ); @@ -52,7 +52,7 @@ public function testTempFile1() { */ public function testTempFile2() { $file_name_prefix = 'myfilename2'; - $file_name_extension = 'txt'; + $file_name_extension = ''; $file_contents = 'mycontentsofthefile2' . PHP_EOL; $temp_file_name = vipgoci_save_temp_file( @@ -76,12 +76,55 @@ public function testTempFile2() { $temp_file_name ); - $this->assertEquals( + $this->assertSame( + $file_name_extension, + $temp_file_extension + ); + + $this->assertSame( + $file_contents, + $temp_file_contents + ); + + unlink( $temp_file_name ); + } + + + /** + * @covers ::vipgoci_save_temp_file + */ + public function testTempFile3() { + $file_name_prefix = 'myfilename3'; + $file_name_extension = 'txt'; + $file_contents = 'mycontentsofthefile3' . PHP_EOL; + + $temp_file_name = vipgoci_save_temp_file( + $file_name_prefix, + $file_name_extension, + $file_contents + ); + + $this->assertNotEquals( + false, + $temp_file_name + ); + + + $temp_file_extension = pathinfo( + $temp_file_name, + PATHINFO_EXTENSION + ); + + $temp_file_contents = file_get_contents( + $temp_file_name + ); + + $this->assertSame( $file_name_extension, $temp_file_extension ); - $this->assertEquals( + $this->assertSame( $file_contents, $temp_file_contents ); From c52d2eecf6061b2000dc016c9197dd037f298af1 Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Fri, 7 May 2021 12:25:24 +0000 Subject: [PATCH 20/25] Replace assertEquals() with assertSame(), along with adjustments --- tests/MiscGitHubPrRemoveDraftsTest.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/MiscGitHubPrRemoveDraftsTest.php b/tests/MiscGitHubPrRemoveDraftsTest.php index 475ebe094..0bc51737e 100644 --- a/tests/MiscGitHubPrRemoveDraftsTest.php +++ b/tests/MiscGitHubPrRemoveDraftsTest.php @@ -31,9 +31,13 @@ public function testRemoveDraftPrs() { $prs_array ); - $this->assertEquals( + if ( isset( $prs_array[ 1 ] ) ) { + $prs_array[ 1 ] = (array) $prs_array[ 1 ]; + } + + $this->assertSame( array( - 1 => (object) array( + 1 => array( 'url' => 'https://myapi2.mydomain.is', 'id' => 999, 'node_id' => 'testing2', From 9b2b7f511e6ed7651565b278b7e0f293031c5985 Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Fri, 7 May 2021 12:26:24 +0000 Subject: [PATCH 21/25] Replace assertEquals() with assertSame(), along with adjustments --- tests/SvgScanScanSingleFileTest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/SvgScanScanSingleFileTest.php b/tests/SvgScanScanSingleFileTest.php index 5a6c9e7c4..b57014481 100644 --- a/tests/SvgScanScanSingleFileTest.php +++ b/tests/SvgScanScanSingleFileTest.php @@ -136,7 +136,8 @@ public function testSvgScanSingleFileTest1() { ) ), ), - + + 'file_issues_str' => '', 'temp_file_name' => $temp_file_name, ); @@ -144,7 +145,7 @@ public function testSvgScanSingleFileTest1() { $expected_result['file_issues_arr_master'] ); - $this->assertEquals( + $this->assertSame( $expected_result, $ret ); From fe84b956ffde23a966d1c0f3ae1ec71f821cba1f Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Fri, 7 May 2021 12:39:36 +0000 Subject: [PATCH 22/25] Adjust, require token to run --- tests/ResultsFilterCommentsToMaxTest.php | 34 ++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/tests/ResultsFilterCommentsToMaxTest.php b/tests/ResultsFilterCommentsToMaxTest.php index 6ed696c9b..47f5d7a7d 100644 --- a/tests/ResultsFilterCommentsToMaxTest.php +++ b/tests/ResultsFilterCommentsToMaxTest.php @@ -104,6 +104,16 @@ protected function tearDown(): void { * @covers ::vipgoci_results_filter_comments_to_max */ public function testResultsFilterCommentsToMax1() { + $options_test = vipgoci_unittests_options_test( + $this->options, + array( ), + $this + ); + + if ( -1 === $options_test ) { + return; + } + /* * Test with max 1 comments allowed. */ @@ -149,6 +159,16 @@ public function testResultsFilterCommentsToMax1() { * @covers ::vipgoci_results_filter_comments_to_max */ public function testResultsFilterCommentsToMax2() { + $options_test = vipgoci_unittests_options_test( + $this->options, + array( ), + $this + ); + + if ( -1 === $options_test ) { + return; + } + /* * Exactly one more comment allowed. */ @@ -157,8 +177,8 @@ public function testResultsFilterCommentsToMax2() { $this->options, $this->options['pr-test-github-pr-results-max'], array( - 'login' => 'myself', - 'comments_active' => true, + 'login' => 'myself', + 'comments_active' => true, ) ) ); @@ -220,6 +240,16 @@ public function testResultsFilterCommentsToMax2() { * @covers ::vipgoci_results_filter_comments_to_max */ public function testResultsFilterCommentsToMax3() { + $options_test = vipgoci_unittests_options_test( + $this->options, + array( ), + $this + ); + + if ( -1 === $options_test ) { + return; + } + /* * Max 100 allowed */ From ee882ff2f0cdfb9c680927762493d89c93412b6f Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Fri, 7 May 2021 13:00:49 +0000 Subject: [PATCH 23/25] Improved tests --- tests/GitHubPrReviewsCommentsGetByPrTest.php | 85 ++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/tests/GitHubPrReviewsCommentsGetByPrTest.php b/tests/GitHubPrReviewsCommentsGetByPrTest.php index 2254b2827..10b7ff726 100644 --- a/tests/GitHubPrReviewsCommentsGetByPrTest.php +++ b/tests/GitHubPrReviewsCommentsGetByPrTest.php @@ -97,4 +97,89 @@ public function testGitHubPrReviewsCommentsGetByPr1() { $comments_actual[0]->body ); } + + /** + * @covers ::vipgoci_github_pr_reviews_comments_get_by_pr + */ + public function testGitHubPrReviewsCommentsGetByPr2() { + $options_test = vipgoci_unittests_options_test( + $this->options, + array( 'github-token', 'token' ), + $this + ); + + if ( -1 === $options_test ) { + return; + } + + vipgoci_unittests_output_suppress(); + + $comments_actual = vipgoci_github_pr_reviews_comments_get_by_pr( + $this->options, + $this->options['pr-test-github-pr-reviews-get-1'], + array( + 'login' => 'gudmdharalds', + ) + ); + + vipgoci_unittests_output_unsuppress(); + + $this->assertSame( + 1, + count( $comments_actual ) + ); + + $this->assertSame( + 264037556, + $comments_actual[0]->id + ); + + + $this->assertSame( + 'file1.php', + $comments_actual[0]->path + ); + + $this->assertSame( + 3, + $comments_actual[0]->position + ); + + $this->assertSame( + 'All output should be escaped.', + $comments_actual[0]->body + ); + } + + /** + * @covers ::vipgoci_github_pr_reviews_comments_get_by_pr + */ + public function testGitHubPrReviewsCommentsGetByPr3() { + $options_test = vipgoci_unittests_options_test( + $this->options, + array( 'github-token', 'token' ), + $this + ); + + if ( -1 === $options_test ) { + return; + } + + vipgoci_unittests_output_suppress(); + + $comments_actual = vipgoci_github_pr_reviews_comments_get_by_pr( + $this->options, + $this->options['pr-test-github-pr-reviews-get-1'], + array( + 'login' => 'random_invalid_user___0x0', + ) + ); + + vipgoci_unittests_output_unsuppress(); + + $this->assertSame( + 0, + count( $comments_actual ) + ); + } } From beb0e82c633f29705c25de4c4cb07ecf1710dfc9 Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Fri, 7 May 2021 14:41:01 +0000 Subject: [PATCH 24/25] Require username to be longer than zero --- tests/GitHubAuthenticatedUserGetTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/GitHubAuthenticatedUserGetTest.php b/tests/GitHubAuthenticatedUserGetTest.php index 5d481ad16..8a4b76ad4 100644 --- a/tests/GitHubAuthenticatedUserGetTest.php +++ b/tests/GitHubAuthenticatedUserGetTest.php @@ -49,6 +49,10 @@ public function testGitHubAuthenticatedUserGet1 () { isset( $gh_result->login ) + && + ( strlen( + $gh_result->login + ) > 0 ) ); } } From 2468440af7bb7a1c3e8e8ebbcdf4f6eae32db7bb Mon Sep 17 00:00:00 2001 From: Gudmundur Haraldsson Date: Fri, 7 May 2021 14:57:12 +0000 Subject: [PATCH 25/25] Adding additional testing --- tests/GitHubRateLimitUsageTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/GitHubRateLimitUsageTest.php b/tests/GitHubRateLimitUsageTest.php index a62c8ce3c..7b5bc3c9c 100644 --- a/tests/GitHubRateLimitUsageTest.php +++ b/tests/GitHubRateLimitUsageTest.php @@ -49,18 +49,30 @@ public function testGitHubRateLimitUsage1 () { isset( $gh_result->resources->core->used ) + && + ( + is_numeric( $gh_result->resources->core->used ) + ) ); $this->assertTrue( isset( $gh_result->resources->core->limit ) + && + ( + is_numeric( $gh_result->resources->core->limit ) + ) ); $this->assertTrue( isset( $gh_result->resources->core->remaining ) + && + ( + is_numeric( $gh_result->resources->core->remaining ) + ) ); } }