Skip to content

Commit

Permalink
[#jira] Test changes
Browse files Browse the repository at this point in the history
  • Loading branch information
larowlan committed Jan 21, 2019
1 parent 5e1bc55 commit 3ee9742
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 44 deletions.
15 changes: 3 additions & 12 deletions tests/Commands/AliasTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ class AliasTest extends TlTestBase {
* @covers ::execute
*/
public function testCreate() {
$this->getMockConnector()->expects($this->any())
->method('ticketDetails')
->with(1234)
->willReturn(new Ticket('Running tests', 123));
$this->setupConnector();
$output = $this->executeCommand('alias', [
'ticket_id' => 1234,
'alias' => 'pony',
Expand All @@ -35,10 +32,7 @@ public function testCreate() {
* @covers ::execute
*/
public function testDelete() {
$this->getMockConnector()->expects($this->any())
->method('ticketDetails')
->with(1234)
->willReturn(new Ticket('Running tests', 123));
$this->setupConnector();
$output = $this->executeCommand('alias', [
'ticket_id' => 1234,
'alias' => 'pony',
Expand All @@ -56,10 +50,7 @@ public function testDelete() {
* @covers ::execute
*/
public function testList() {
$this->getMockConnector()->expects($this->any())
->method('ticketDetails')
->with(1234)
->willReturn(new Ticket('Running tests', 123));
$this->setupConnector();
$aliases = [
'some',
'drunk',
Expand Down
5 changes: 1 addition & 4 deletions tests/Commands/LogTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ class LogTest extends TlTestBase {
* @covers ::execute
*/
public function testLogging() {
$this->getMockConnector()->expects($this->any())
->method('ticketDetails')
->with(1234)
->willReturn(new Ticket('Running tests', 123));
$this->setupConnector();
$output = new StreamOutput(fopen('php://memory', 'w', FALSE));
$command = $this->container->get('app.command.start');
$command->setApplication($this->application);
Expand Down
35 changes: 7 additions & 28 deletions tests/Commands/StartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ public function testStart() {
* @covers \Larowlan\Tl\Application::doRun
*/
public function testStartLogging() {
$this->getMockConnector()->expects($this->any())
->method('ticketDetails')
->with(1234)
->willReturn(new Ticket('Running tests', 123));
$this->setupConnector();
$output = new StreamOutput(fopen('php://memory', 'w', FALSE));
$command = $this->container->get('app.command.start');
$command->setApplication($this->application);
Expand Down Expand Up @@ -84,10 +81,7 @@ public function testStopStart() {
* @covers ::execute
*/
public function testStartWithComment() {
$this->getMockConnector()->expects($this->any())
->method('ticketDetails')
->with(1234)
->willReturn(new Ticket('Running tests', 123));
$this->setupConnector();
$output = $this->executeCommand('start', [
'issue_number' => 1234,
'comment' => 'Doing stuff',
Expand All @@ -100,10 +94,7 @@ public function testStartWithComment() {
* @covers ::execute
*/
public function testAssign() {
$this->getMockConnector()->expects($this->any())
->method('ticketDetails')
->with(1234)
->willReturn(new Ticket('Running tests', 123));
$this->setupConnector();
$this->getMockConnector()->expects($this->once())
->method('assign')
->with(1234)
Expand All @@ -121,10 +112,7 @@ public function testAssign() {
* @covers ::execute
*/
public function testAssignShortSyntax() {
$this->getMockConnector()->expects($this->any())
->method('ticketDetails')
->with(1234)
->willReturn(new Ticket('Running tests', 123));
$this->setupConnector();
$this->getMockConnector()->expects($this->once())
->method('assign')
->with(1234)
Expand All @@ -142,10 +130,7 @@ public function testAssignShortSyntax() {
* @covers ::execute
*/
public function testAssignAlreadyAssigned() {
$this->getMockConnector()->expects($this->any())
->method('ticketDetails')
->with(1234)
->willReturn(new Ticket('Running tests', 123));
$this->setupConnector();
$this->getMockConnector()->expects($this->once())
->method('assign')
->with(1234)
Expand All @@ -163,10 +148,7 @@ public function testAssignAlreadyAssigned() {
* @covers ::execute
*/
public function testStatus() {
$this->getMockConnector()->expects($this->any())
->method('ticketDetails')
->with(1234)
->willReturn(new Ticket('Running tests', 123));
$this->setupConnector();
$this->getMockConnector()->expects($this->once())
->method('setInProgress')
->with(1234)
Expand Down Expand Up @@ -261,10 +243,7 @@ public function testStatusAssignAndComment() {
* @covers ::execute
*/
public function testStatusAlreadyInProgress() {
$this->getMockConnector()->expects($this->any())
->method('ticketDetails')
->with(1234)
->willReturn(new Ticket('Running tests', 123));
$this->setupConnector();
$this->getMockConnector()->expects($this->once())
->method('setInProgress')
->with(1234)
Expand Down
15 changes: 15 additions & 0 deletions tests/TlTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Larowlan\Tl\Application;
use Larowlan\Tl\Connector\ConnectorManager;
use Larowlan\Tl\Tests\Commands\AliasTest;
use Larowlan\Tl\Ticket;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Config\FileLocator;
Expand Down Expand Up @@ -140,4 +142,17 @@ protected function assertTicketIsOpen($ticket_id, $comment = NULL) {
return $active;
}

/**
* Sets up connector.
*/
protected function setupConnector() {
$this->getMockConnector()->expects($this->any())
->method('ticketDetails')
->with(1234, 'connector.redmine')
->willReturn(new Ticket('Running tests', 123));
$this->getMockConnector()->expects($this->any())
->method('spotConnector')
->willReturn('connector.redmine');
}

}

0 comments on commit 3ee9742

Please sign in to comment.