Skip to content

Commit 1709b6c

Browse files
Merge pull request #48 from utopia-php/chore-assert-same
Chore: Replace assertEquals with assertSame
2 parents 28457cf + 4b6ed63 commit 1709b6c

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

tests/VCS/Adapter/GitHubTest.php

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,16 @@ public function testgetEvent(): void
114114
';
115115

116116
$pushResult = $this->vcsAdapter->getEvent('push', $payload_push);
117-
$this->assertEquals('main', $pushResult['branch']);
118-
$this->assertEquals('603754812', $pushResult['repositoryId']);
117+
$this->assertSame('main', $pushResult['branch']);
118+
$this->assertSame('603754812', $pushResult['repositoryId']);
119119

120120
$pullRequestResult = $this->vcsAdapter->getEvent('pull_request', $payload_pull_request);
121-
$this->assertEquals('opened', $pullRequestResult['action']);
122-
$this->assertEquals(1, $pullRequestResult['pullRequestNumber']);
121+
$this->assertSame('opened', $pullRequestResult['action']);
122+
$this->assertSame(1, $pullRequestResult['pullRequestNumber']);
123123

124124
$uninstallResult = $this->vcsAdapter->getEvent('installation', $payload_uninstall);
125-
$this->assertEquals('deleted', $uninstallResult['action']);
126-
$this->assertEquals(1234, $uninstallResult['installationId']);
125+
$this->assertSame('deleted', $uninstallResult['action']);
126+
$this->assertSame('1234', $uninstallResult['installationId']);
127127
}
128128

129129
public function testGetComment(): void
@@ -141,7 +141,7 @@ public function testGetComment(): void
141141
public function testGetRepositoryName(): void
142142
{
143143
$repositoryName = $this->vcsAdapter->getRepositoryName('432284323');
144-
$this->assertEquals('basic-js-crud', $repositoryName);
144+
$this->assertSame('basic-js-crud', $repositoryName);
145145
}
146146

147147
public function testGetRepositoryTree(): void
@@ -171,14 +171,14 @@ public function testGetRepositoryTree(): void
171171
$tree = $this->vcsAdapter->getRepositoryTree($owner, $repositoryName, $branch, true);
172172
$this->assertIsArray($tree);
173173
$this->assertNotEmpty($tree);
174-
$this->assertEquals('src/folder/README.md', $tree[2]);
174+
$this->assertSame('src/folder/README.md', $tree[2]);
175175

176176
// test for recursive false
177177
$repositoryName = 'test4';
178178
$tree = $this->vcsAdapter->getRepositoryTree($owner, $repositoryName, $branch);
179179
$this->assertIsArray($tree);
180180
$this->assertNotEmpty($tree);
181-
$this->assertEquals(1, count($tree));
181+
$this->assertSame(1, count($tree));
182182
}
183183

184184
public function testGetRepositoryContent(): void
@@ -188,21 +188,21 @@ public function testGetRepositoryContent(): void
188188

189189
// Basic usage
190190
$response = $this->vcsAdapter->getRepositoryContent($owner, $repositoryName, 'README.md');
191-
$this->assertEquals('# test1', $response['content']);
191+
$this->assertSame('# test1', $response['content']);
192192

193193
$sha = \hash('sha1', "blob " . $response['size'] . "\0" . $response['content']);
194-
$this->assertEquals(7, $response['size']);
195-
$this->assertEquals($sha, $response['sha']);
194+
$this->assertSame(7, $response['size']);
195+
$this->assertSame($sha, $response['sha']);
196196

197197
$response = $this->vcsAdapter->getRepositoryContent($owner, $repositoryName, 'src/index.md');
198-
$this->assertEquals("Hello\n", $response['content']);
198+
$this->assertSame("Hello\n", $response['content']);
199199

200200
// Branches
201201
$response = $this->vcsAdapter->getRepositoryContent($owner, $repositoryName, 'README.md', 'main');
202-
$this->assertEquals('# test1', $response['content']);
202+
$this->assertSame('# test1', $response['content']);
203203

204204
$response = $this->vcsAdapter->getRepositoryContent($owner, $repositoryName, 'README.md', 'test');
205-
$this->assertEquals("# test1 from test branch\n", $response['content']);
205+
$this->assertSame("# test1 from test branch\n", $response['content']);
206206

207207
$threw = false;
208208
try {
@@ -285,9 +285,9 @@ public function testGetPullRequest(): void
285285

286286
$this->assertIsArray($result);
287287
$this->assertNotEmpty($result);
288-
$this->assertEquals($pullRequestNumber, $result['number']);
289-
$this->assertEquals($owner, $result['base']['user']['login']);
290-
$this->assertEquals($repositoryName, $result['base']['repo']['name']);
288+
$this->assertSame($pullRequestNumber, $result['number']);
289+
$this->assertSame($owner, $result['base']['user']['login']);
290+
$this->assertSame($repositoryName, $result['base']['repo']['name']);
291291
}
292292

293293
public function testGenerateCloneCommand(): void
@@ -299,7 +299,7 @@ public function testGenerateCloneCommand(): void
299299
$output = '';
300300
$resultCode = null;
301301
\exec($gitCloneCommand, $output, $resultCode);
302-
$this->assertEquals(0, $resultCode);
302+
$this->assertSame(0, $resultCode);
303303

304304
$this->assertFileExists('/tmp/clone-branch/README.md');
305305
}
@@ -313,7 +313,7 @@ public function testGenerateCloneCommandWithCommitHash(): void
313313
$output = '';
314314
$resultCode = null;
315315
\exec($gitCloneCommand, $output, $resultCode);
316-
$this->assertEquals(0, $resultCode);
316+
$this->assertSame(0, $resultCode);
317317

318318
$this->assertFileExists('/tmp/clone-commit/README.md');
319319
}
@@ -327,7 +327,7 @@ public function testGenerateCloneCommandWithTag(): void
327327
$output = '';
328328
$resultCode = null;
329329
\exec($gitCloneCommand, $output, $resultCode);
330-
$this->assertEquals(0, $resultCode);
330+
$this->assertSame(0, $resultCode);
331331

332332
$this->assertFileExists('/tmp/clone-tag/README.md');
333333

@@ -338,7 +338,7 @@ public function testGenerateCloneCommandWithTag(): void
338338
$output = '';
339339
$resultCode = null;
340340
\exec($gitCloneCommand, $output, $resultCode);
341-
$this->assertEquals(0, $resultCode);
341+
$this->assertSame(0, $resultCode);
342342

343343
$this->assertFileExists('/tmp/clone-tag2/README.md');
344344

@@ -349,7 +349,7 @@ public function testGenerateCloneCommandWithTag(): void
349349
$output = '';
350350
$resultCode = null;
351351
\exec($gitCloneCommand, $output, $resultCode);
352-
$this->assertEquals(0, $resultCode);
352+
$this->assertSame(0, $resultCode);
353353

354354
$this->assertFileExists('/tmp/clone-tag3/README.md');
355355

@@ -376,19 +376,19 @@ public function testGetCommit(): void
376376
{
377377
$commitDetails = $this->vcsAdapter->getCommit('test-kh', 'test1', '7ae65094d56edafc48596ffbb77950e741e56412');
378378
$this->assertIsArray($commitDetails);
379-
$this->assertEquals('https://avatars.githubusercontent.com/u/43381712?v=4', $commitDetails['commitAuthorAvatar']);
380-
$this->assertEquals('https://github.com/vermakhushboo', $commitDetails['commitAuthorUrl']);
381-
$this->assertEquals('Khushboo Verma', $commitDetails['commitAuthor']);
382-
$this->assertEquals('Initial commit', $commitDetails['commitMessage']);
383-
$this->assertEquals('https://github.com/test-kh/test1/commit/7ae65094d56edafc48596ffbb77950e741e56412', $commitDetails['commitUrl']);
384-
$this->assertEquals('7ae65094d56edafc48596ffbb77950e741e56412', $commitDetails['commitHash']);
379+
$this->assertSame('https://avatars.githubusercontent.com/u/43381712?v=4', $commitDetails['commitAuthorAvatar']);
380+
$this->assertSame('https://github.com/vermakhushboo', $commitDetails['commitAuthorUrl']);
381+
$this->assertSame('Khushboo Verma', $commitDetails['commitAuthor']);
382+
$this->assertSame('Initial commit', $commitDetails['commitMessage']);
383+
$this->assertSame('https://github.com/test-kh/test1/commit/7ae65094d56edafc48596ffbb77950e741e56412', $commitDetails['commitUrl']);
384+
$this->assertSame('7ae65094d56edafc48596ffbb77950e741e56412', $commitDetails['commitHash']);
385385
}
386386

387387
public function testGetLatestCommit(): void
388388
{
389389
$commitDetails = $this->vcsAdapter->getLatestCommit('test-kh', 'test1', 'test');
390-
$this->assertEquals('Khushboo Verma', $commitDetails['commitAuthor']);
391-
$this->assertEquals('https://avatars.githubusercontent.com/u/43381712?v=4', $commitDetails['commitAuthorAvatar']);
392-
$this->assertEquals('https://github.com/vermakhushboo', $commitDetails['commitAuthorUrl']);
390+
$this->assertSame('Khushboo Verma', $commitDetails['commitAuthor']);
391+
$this->assertSame('https://avatars.githubusercontent.com/u/43381712?v=4', $commitDetails['commitAuthorAvatar']);
392+
$this->assertSame('https://github.com/vermakhushboo', $commitDetails['commitAuthorUrl']);
393393
}
394394
}

tests/VCS/Base.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function testGetOwnerName(): void
4646
{
4747
$installationId = System::getEnv('INSTALLATION_ID') ?? '';
4848
$owner = $this->vcsAdapter->getOwnerName($installationId);
49-
$this->assertEquals('test-kh', $owner);
49+
$this->assertSame('test-kh', $owner);
5050
}
5151

5252
public function testSearchRepositories(): void
@@ -119,14 +119,14 @@ public function testListRepositoryContents(): void
119119
$this->assertNotNull($directoryContent);
120120
$this->assertNotEmpty($directoryContent['name']);
121121
$this->assertIsNumeric($directoryContent['size']);
122-
$this->assertEquals(0, $directoryContent['size']);
122+
$this->assertSame(0, $directoryContent['size']);
123123
}
124124

125125
public function testCreateRepository(): void
126126
{
127127
$repository = $this->vcsAdapter->createRepository('test-kh', 'new-repo', true);
128128
$this->assertIsArray($repository);
129-
$this->assertEquals('test-kh/new-repo', $repository['full_name']);
129+
$this->assertSame('test-kh/new-repo', $repository['full_name']);
130130
}
131131

132132
/**
@@ -135,7 +135,7 @@ public function testCreateRepository(): void
135135
public function testDeleteRepository(): void
136136
{
137137
$result = $this->vcsAdapter->deleteRepository('test-kh', 'new-repo');
138-
$this->assertEquals(true, $result);
138+
$this->assertSame(true, $result);
139139
$this->expectException(Exception::class);
140140
$result = $this->vcsAdapter->deleteRepository('test-kh', 'new-repo-2');
141141
}

0 commit comments

Comments
 (0)