Skip to content
This repository was archived by the owner on Dec 8, 2017. It is now read-only.

Commit 60121aa

Browse files
author
Sam Parkinson
committed
Add warning if hook install directory does not exist.
Use assertSame rather than assertEquals where possible.
1 parent 04d49fb commit 60121aa

File tree

8 files changed

+37
-31
lines changed

8 files changed

+37
-31
lines changed

src/Command/HookInstallCommand.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,23 @@ protected function execute(InputInterface $input, OutputInterface $output)
4545
$force = $input->getOption('force');
4646

4747
if ($output->isVeryVerbose()) {
48-
$message = sprintf('<info>Using %s for the hook target.</info>', $target);
48+
$message = sprintf('<info>Using %s for the install path.</info>', $link);
4949
$output->writeln($message);
5050

51-
$message = sprintf('<info>Using %s for the hook.</info>', $link);
51+
$message = sprintf('<info>Using %s as the hook.</info>', $target);
5252
$output->writeln($message);
5353
}
5454

55+
if (! is_dir(dirname($link))) {
56+
$message = sprintf('<error>The directory at %s does not exist.</error>', $link);
57+
$output->writeln($message);
58+
exit(1);
59+
}
60+
5561
if (file_exists($link) && $force) {
5662
unlink($link);
5763

58-
$message = sprintf('<info>Removed existing file at %s.</info>', $link);
64+
$message = sprintf('<comment>Removed existing file at %s.</comment>', $link);
5965
$output->writeln($message);
6066
}
6167

tests/unit/Collection/CollectionTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testConstructorWithArgument()
4040
$this->collection->__construct($items);
4141

4242
for ($i = 0; $i > count($this->collection); $i++) {
43-
$this->assertEquals($items[$i], $this->collection[$i]);
43+
$this->assertSame($items[$i], $this->collection[$i]);
4444
}
4545
}
4646

@@ -62,12 +62,12 @@ public function testAppendWithValidItem()
6262
$this->collection->append($item);
6363

6464
$this->assertCount(1, $this->collection);
65-
$this->assertEquals($item, $this->collection->current());
65+
$this->assertSame($item, $this->collection->current());
6666

6767
$this->collection->append($item);
6868

6969
$this->assertCount(2, $this->collection);
70-
$this->assertEquals($item, $this->collection->next());
70+
$this->assertSame($item, $this->collection->next());
7171
}
7272

7373
/**

tests/unit/Collection/IssueCollectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function testForLevelWithMatchingLevel()
8787
$issues = $this->collection->forLevel(Issue::LEVEL_INFO);
8888

8989
$this->assertCount(1, $issues);
90-
$this->assertEquals($issue, $issues->current());
90+
$this->assertSame($issue, $issues->current());
9191
}
9292

9393
public function testForLevelWithNonMatchingLevel()

tests/unit/Collection/ReviewCollectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function testForFileWithMatchingFile()
8888
$reviews = $this->collection->forFile($file);
8989

9090
$this->assertCount(1, $reviews);
91-
$this->assertEquals($review, $reviews->current());
91+
$this->assertSame($review, $reviews->current());
9292
}
9393

9494
public function testForFileWithNonMatchingFile()

tests/unit/File/FileTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,19 @@ public function testGetFileName()
4242
{
4343
$expected = 'file.php';
4444

45-
$this->assertEquals($expected, $this->file->getFileName());
45+
$this->assertSame($expected, $this->file->getFileName());
4646
}
4747

4848
public function testGetRelativePath()
4949
{
50-
$this->assertEquals($this->filePath, $this->file->getRelativePath());
50+
$this->assertSame($this->filePath, $this->file->getRelativePath());
5151
}
5252

5353
public function testGetFullPathWithNoCachedPath()
5454
{
5555
$expected = $this->projectPath . '/' . $this->filePath;
5656

57-
$this->assertEquals($expected, $this->file->getFullPath());
57+
$this->assertSame($expected, $this->file->getFullPath());
5858
}
5959

6060
public function testGetFullPathWithCachedPath()
@@ -63,7 +63,7 @@ public function testGetFullPathWithCachedPath()
6363

6464
$this->file->setCachedPath($path);
6565

66-
$this->assertEquals($path, $this->file->getFullPath());
66+
$this->assertSame($path, $this->file->getFullPath());
6767
}
6868

6969
public function testGetCachedPath()
@@ -74,7 +74,7 @@ public function testGetCachedPath()
7474

7575
$result = $this->file->setCachedPath($path);
7676

77-
$this->assertEquals($path, $this->file->getCachedPath());
77+
$this->assertSame($path, $this->file->getCachedPath());
7878
}
7979

8080
public function testSetCachedPath()
@@ -83,21 +83,21 @@ public function testSetCachedPath()
8383

8484
$path = '/Test';
8585

86-
$this->assertEquals($this->file, $this->file->setCachedPath($path));
86+
$this->assertSame($this->file, $this->file->setCachedPath($path));
8787

88-
$this->assertEquals($path, $this->file->getCachedPath());
88+
$this->assertSame($path, $this->file->getCachedPath());
8989
}
9090

9191
public function testGetExtension()
9292
{
9393
$expected = pathinfo($this->filePath, PATHINFO_EXTENSION);
9494

95-
$this->assertEquals($expected, $this->file->getExtension());
95+
$this->assertSame($expected, $this->file->getExtension());
9696
}
9797

9898
public function testGetStatus()
9999
{
100-
$this->assertEquals($this->fileStatus, $this->file->getStatus());
100+
$this->assertSame($this->fileStatus, $this->file->getStatus());
101101
}
102102

103103
public function testGetFormattedStatus()

tests/unit/Issue/IssueTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,22 @@ public function tearDown()
5151

5252
public function testGetLevel()
5353
{
54-
$this->assertEquals($this->issueLevel, $this->issue->getLevel());
54+
$this->assertSame($this->issueLevel, $this->issue->getLevel());
5555
}
5656

5757
public function testGetMessage()
5858
{
59-
$this->assertEquals($this->issueMessage, $this->issue->getMessage());
59+
$this->assertSame($this->issueMessage, $this->issue->getMessage());
6060
}
6161

6262
public function testGetReviewName()
6363
{
64-
$this->assertEquals('ReviewInterface', $this->issue->getReviewName());
64+
$this->assertSame('ReviewInterface', $this->issue->getReviewName());
6565
}
6666

6767
public function testGetFile()
6868
{
69-
$this->assertEquals($this->issueFile, $this->issue->getFile());
69+
$this->assertSame($this->issueFile, $this->issue->getFile());
7070
}
7171

7272
public function testGetLevelName()

tests/unit/Reporter/ReporterTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function testInfo()
4949

5050
$this->assertCount(1, $issues);
5151

52-
$this->assertEquals(Issue::LEVEL_INFO, $issues->current()->getLevel());
52+
$this->assertSame(Issue::LEVEL_INFO, $issues->current()->getLevel());
5353
}
5454

5555
public function testWarning()
@@ -60,7 +60,7 @@ public function testWarning()
6060

6161
$this->assertCount(1, $issues);
6262

63-
$this->assertEquals(Issue::LEVEL_WARNING, $issues->current()->getLevel());
63+
$this->assertSame(Issue::LEVEL_WARNING, $issues->current()->getLevel());
6464
}
6565

6666
public function testError()
@@ -71,7 +71,7 @@ public function testError()
7171

7272
$this->assertCount(1, $issues);
7373

74-
$this->assertEquals(Issue::LEVEL_ERROR, $issues->current()->getLevel());
74+
$this->assertSame(Issue::LEVEL_ERROR, $issues->current()->getLevel());
7575
}
7676

7777
public function testHasIssues()
@@ -101,7 +101,7 @@ public function testGetIssues()
101101
$this->assertCount(3, $this->reporter->getIssues());
102102

103103
foreach($this->reporter->getIssues() as $issue) {
104-
$this->assertEquals('Test', $issue->getMessage());
104+
$this->assertSame('Test', $issue->getMessage());
105105
}
106106
}
107107
}

tests/unit/StaticReviewTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ public function tearDown()
4242

4343
public function testGetReporter()
4444
{
45-
$this->assertEquals($this->reporter, $this->staticReview->getReporter());
45+
$this->assertSame($this->reporter, $this->staticReview->getReporter());
4646
}
4747

4848
public function testSetReporter()
4949
{
5050
$newReporter = Mockery::mock('StaticReview\Reporter\ReporterInterface');
5151

52-
$this->assertEquals($this->staticReview, $this->staticReview->setReporter($newReporter));
52+
$this->assertSame($this->staticReview, $this->staticReview->setReporter($newReporter));
5353

54-
$this->assertEquals($newReporter, $this->staticReview->getReporter());
54+
$this->assertSame($newReporter, $this->staticReview->getReporter());
5555
}
5656

5757
public function testGetReviews()
@@ -67,7 +67,7 @@ public function testAddReview()
6767
{
6868
$this->assertCount(0, $this->staticReview->getReviews());
6969

70-
$this->assertEquals($this->staticReview, $this->staticReview->addReview($this->review));
70+
$this->assertSame($this->staticReview, $this->staticReview->addReview($this->review));
7171
$this->assertCount(1, $this->staticReview->getReviews());
7272
}
7373

@@ -77,7 +77,7 @@ public function testAddReviews()
7777

7878
$reviews = new ReviewCollection([$this->review, $this->review]);
7979

80-
$this->assertEquals($this->staticReview, $this->staticReview->addReviews($reviews));
80+
$this->assertSame($this->staticReview, $this->staticReview->addReviews($reviews));
8181
$this->assertCount(2, $this->staticReview->getReviews());
8282
}
8383

@@ -94,6 +94,6 @@ public function testReview()
9494

9595
$this->staticReview->addReviews($reviews);
9696

97-
$this->assertEquals($this->staticReview, $this->staticReview->review($files));
97+
$this->assertSame($this->staticReview, $this->staticReview->review($files));
9898
}
9999
}

0 commit comments

Comments
 (0)