-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from larowlan/120-visit-alias
[#120] Support aliases in tl visit.
- Loading branch information
Showing
3 changed files
with
102 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
|
||
namespace Larowlan\Tl\Tests\Commands; | ||
|
||
use Larowlan\Tl\Tests\TlTestBase; | ||
|
||
/** | ||
* The test for tl visit command. | ||
* | ||
* @coversDefaultClass \Larowlan\Tl\Commands\Visit | ||
* @group Commands | ||
*/ | ||
class VisitTest extends TlTestBase { | ||
|
||
/** | ||
* Tests visit command with minimum params. | ||
* | ||
* @covers ::execute | ||
*/ | ||
public function testNoActiveVisit() { | ||
$output = $this->executeCommand('visit'); | ||
$this->assertContains('No active ticket, please use tl visit {ticket_id} to specifiy a ticket.', $output->getDisplay()); | ||
} | ||
|
||
/** | ||
* Tests visit command with active ticket. | ||
* | ||
* @covers ::execute | ||
*/ | ||
public function testActiveVisit() { | ||
$this->setupConnector(); | ||
$this->getMockConnector()->expects($this->once()) | ||
->method('ticketUrl') | ||
->with(1234, 'connector.redmine') | ||
->willReturn('https://www.jetbrains.com'); | ||
$this->executeCommand('start', [ | ||
'issue_number' => '1234', | ||
]); | ||
$this->assertTicketIsOpen(1234); | ||
$output = $this->executeCommand('visit'); | ||
$this->assertContains('Could not find a browser helper.', $output->getDisplay()); | ||
} | ||
|
||
/** | ||
* Tests visit command with issue param. | ||
* | ||
* @covers ::execute | ||
*/ | ||
public function testIssueVisit() { | ||
$this->setupConnector(); | ||
$this->getMockConnector()->expects($this->once()) | ||
->method('ticketUrl') | ||
->with(1234, 'connector.redmine') | ||
->willReturn('https://www.jetbrains.com'); | ||
$output = $this->executeCommand('visit', [ | ||
'issue' => '1234', | ||
]); | ||
$this->assertContains('Could not find a browser helper.', $output->getDisplay()); | ||
} | ||
|
||
/** | ||
* Tests visit command with issue alias param. | ||
* | ||
* @covers ::execute | ||
*/ | ||
public function testAliasVisit() { | ||
$this->setupConnector(); | ||
$this->getMockConnector()->expects($this->once()) | ||
->method('ticketUrl') | ||
->with(1234, 'connector.redmine') | ||
->willReturn('https://www.jetbrains.com'); | ||
$output = $this->executeCommand('alias', [ | ||
'ticket_id' => 1234, | ||
'alias' => 'pony', | ||
]); | ||
$this->assertRegExp('/Created new alias/', $output->getDisplay()); | ||
$output = $this->executeCommand('visit', [ | ||
'issue' => 'pony', | ||
]); | ||
$this->assertContains('Could not find a browser helper.', $output->getDisplay()); | ||
} | ||
|
||
/** | ||
* Tests visit command with invalid issue. | ||
* | ||
* @covers ::execute | ||
*/ | ||
public function testInvalidTicketVisit() { | ||
$this->getMockConnector()->expects($this->once()) | ||
->method('spotConnector') | ||
->willReturn(FALSE); | ||
$this->expectException(\InvalidArgumentException::class); | ||
$this->executeCommand('visit', [ | ||
'issue' => '5678', | ||
]); | ||
} | ||
|
||
} |