Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a few unit-tests, replacing assertEquals() with assertSame() #167

Merged
merged 25 commits into from
May 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8c5ef90
Adding unit-test for vipgoci_cached_indication_str()
gudmdharalds May 5, 2021
d5b9dfc
Add namespace, disable a particular PHPCS sniff
gudmdharalds May 5, 2021
38f6ce8
Disable a certain PHPCS sniff
gudmdharalds May 5, 2021
060522a
Adding unit-test for vipgoci_github_rate_limit_usage()
gudmdharalds May 5, 2021
5144800
Adding test for vipgoci_github_authenticated_user_get()
gudmdharalds May 5, 2021
988d9d2
Code coverage not possible for vipgoci_curl_set_security_options()
gudmdharalds May 5, 2021
6b1b964
Use assertSame()
gudmdharalds May 5, 2021
74df7b9
Adding test for vipgoci_option_skip_folder_handle()
gudmdharalds May 7, 2021
df39630
Adding test for vipgoci_results_filter_comments_to_max()
gudmdharalds May 7, 2021
303a4c9
Adding config option for test
gudmdharalds May 7, 2021
75ef19b
Replacing assertEquals() with assertSame()
gudmdharalds May 7, 2021
3038c33
Replacing assertEquals() with assertSame()
gudmdharalds May 7, 2021
34f28bd
Replacing assertEquals() with assertSame()
gudmdharalds May 7, 2021
362bdd8
Replace assertEquals() with assertSame()
gudmdharalds May 7, 2021
ac51b0e
Replace assertEquals() with assertSame(), along with adjustments
gudmdharalds May 7, 2021
7090014
Replace assertEquals() with assertSame(), along with adjustments
gudmdharalds May 7, 2021
0127ff5
Replace assertEquals() with assertSame(), along with adjustments
gudmdharalds May 7, 2021
0838eac
Replace assertEquals() with assertSame(), along with adjustments
gudmdharalds May 7, 2021
87eab1d
Replace assertEquals() with assertSame(), along with adjustments
gudmdharalds May 7, 2021
c52d2ee
Replace assertEquals() with assertSame(), along with adjustments
gudmdharalds May 7, 2021
9b2b7f5
Replace assertEquals() with assertSame(), along with adjustments
gudmdharalds May 7, 2021
fe84b95
Adjust, require token to run
gudmdharalds May 7, 2021
ee882ff
Improved tests
gudmdharalds May 7, 2021
beb0e82
Require username to be longer than zero
gudmdharalds May 7, 2021
2468440
Adding additional testing
gudmdharalds May 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions github-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
/*
Expand Down Expand Up @@ -155,8 +157,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(
Expand Down
2 changes: 1 addition & 1 deletion tests/A00IrcApiAlertQueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function testIrcQueue1() {
true
);

$this->assertEquals(
$this->assertSame(
array(
'mymessage1',
'mymessage2',
Expand Down
12 changes: 6 additions & 6 deletions tests/A00StatsCountersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ final class A00StatsCountersTest extends TestCase {
* @covers ::vipgoci_counter_report
*/
function testCounterReport1() {
$this->assertEquals(
$this->assertSame(
vipgoci_counter_report(
'illegalaction',
'mycounter1',
Expand All @@ -18,7 +18,7 @@ function testCounterReport1() {
false
);

$this->assertEquals(
$this->assertSame(
array(),
vipgoci_counter_report(
VIPGOCI_COUNTERS_DUMP
Expand All @@ -30,7 +30,7 @@ function testCounterReport1() {
* @covers ::vipgoci_counter_report
*/
function testCounterReport2() {
$this->assertEquals(
$this->assertSame(
true,
vipgoci_counter_report(
VIPGOCI_COUNTERS_DO,
Expand All @@ -39,7 +39,7 @@ function testCounterReport2() {
)
);

$this->assertEquals(
$this->assertSame(
true,
vipgoci_counter_report(
VIPGOCI_COUNTERS_DO,
Expand All @@ -48,7 +48,7 @@ function testCounterReport2() {
)
);

$this->assertEquals(
$this->assertSame(
array(
'mycounter2' => 101,
),
Expand Down Expand Up @@ -92,7 +92,7 @@ function testCounterUpdateWithIssuesFound1() {
unset( $report['mycounter2'] );


$this->assertEquals(
$this->assertSame(
array(
'github_pr_unique_issue_issues' => 3,
),
Expand Down
6 changes: 3 additions & 3 deletions tests/A09GitHubLabelsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down Expand Up @@ -123,7 +123,7 @@ public function testGitHubRemoveLabel1() {

$labels_after = $this->labels_get();

$this->assertEquals(
$this->assertSame(
1,
count( $labels_before ) - count( $labels_after )
);
Expand Down
8 changes: 4 additions & 4 deletions tests/A09LintLintScanCommitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -170,7 +170,7 @@ public function testLintDoScan1() {
$issues_submit
);

$this->assertEquals(
$this->assertSame(
array(
$pr_item->number => array(
'error' => 1,
Expand Down Expand Up @@ -279,7 +279,7 @@ public function testLintDoScan2() {
);


$this->assertEquals(
$this->assertSame(
array(
$pr_item->number => array(
array(
Expand Down Expand Up @@ -312,7 +312,7 @@ public function testLintDoScan2() {
$issues_submit
);

$this->assertEquals(
$this->assertSame(
array(
$pr_item->number => array(
'error' => 2,
Expand Down
2 changes: 1 addition & 1 deletion tests/AllUnitTestsInplaceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function( $file_item ) {
/*
* We should end with an empty array.
*/
$this->assertEquals(
$this->assertSame(
0,
count( $files_arr )
);
Expand Down
45 changes: 24 additions & 21 deletions tests/ApAutoApprovalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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
);
Expand Down Expand Up @@ -302,7 +305,7 @@ public function testAutoApproval2() {

vipgoci_unittests_output_unsuppress();

$this->assertEquals(
$this->assertSame(
array(),
$results
);
Expand All @@ -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
);
Expand All @@ -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
);
Expand All @@ -361,7 +364,7 @@ public function testAutoApproval2() {

$labels = $this->pr_get_labels();

$this->assertEquals(
$this->assertSame(
$this->options['autoapprove-label'],
$labels->name
);
Expand Down Expand Up @@ -424,7 +427,7 @@ public function testAutoApproval3() {

vipgoci_unittests_output_unsuppress();

$this->assertEquals(
$this->assertSame(
array(),
$results
);
Expand All @@ -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
);
Expand All @@ -468,15 +471,15 @@ public function testAutoApproval3() {

vipgoci_unittests_output_unsuppress();

$this->assertEquals(
$this->assertSame(
0,
count( $pr_item_reviews )
);
}

$label = $this->pr_get_labels();

$this->assertEquals(
$this->assertSame(
false,
$label
);
Expand Down Expand Up @@ -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
);
Expand All @@ -585,28 +588,28 @@ public function testAutoApproval4() {

vipgoci_unittests_output_unsuppress();

$this->assertEquals(
$this->assertSame(
0,
count( $pr_item_reviews )
);
}

$label = $this->pr_get_labels();

$this->assertEquals(
$this->assertSame(
false,
$label
);

$this->assertEquals(
$this->assertSame(
1,
$results['stats']
[ VIPGOCI_STATS_HASHES_API ]
[ $this->options['pr-test-ap-auto-approval-1'] ]
[ 'info' ]
);

$this->assertEquals(
$this->assertSame(
'file-1.php',
$results['issues']
[ $this->options['pr-test-ap-auto-approval-1'] ]
Expand Down Expand Up @@ -672,7 +675,7 @@ public function testAutoApproval5() {

vipgoci_unittests_output_unsuppress();

$this->assertEquals(
$this->assertSame(
0,
count( $pr_item_reviews )
);
Expand Down Expand Up @@ -727,7 +730,7 @@ public function testAutoApproval5() {

vipgoci_unittests_output_unsuppress();

$this->assertEquals(
$this->assertSame(
1,
count( $pr_item_reviews )
);
Expand Down
4 changes: 2 additions & 2 deletions tests/ApFileTypesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
2 changes: 1 addition & 1 deletion tests/ApHashesApiScanCommitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function testApHashesApiScanCommitTest1() {

vipgoci_unittests_output_unsuppress();

$this->assertEquals(
$this->assertSame(
array(
'auto-approvable-6.php' => 'autoapprove-hashes-to-hashes',
),
Expand Down
2 changes: 1 addition & 1 deletion tests/ApNonfunctionalChangesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 3 additions & 3 deletions tests/ApSvgFilesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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
);
Expand Down
Loading