Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
Replace class strings with class name constants
Browse files Browse the repository at this point in the history
  • Loading branch information
niels-nijens committed May 14, 2016
1 parent b0045dd commit 0583c20
Show file tree
Hide file tree
Showing 6 changed files with 196 additions and 147 deletions.
6 changes: 4 additions & 2 deletions src/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Accompli\Chrono;

use Accompli\Chrono\Adapter\AdapterInterface;
use Accompli\Chrono\Adapter\GitAdapter;
use Accompli\Chrono\Adapter\SubversionAdapter;
use Accompli\Chrono\Process\ProcessExecutorInterface;
use InvalidArgumentException;

Expand Down Expand Up @@ -40,8 +42,8 @@ class Repository implements RepositoryInterface
* @var array
*/
private $adapters = array(
'Accompli\Chrono\Adapter\GitAdapter',
'Accompli\Chrono\Adapter\SubversionAdapter',
GitAdapter::class,
SubversionAdapter::class,
);

/**
Expand Down
7 changes: 5 additions & 2 deletions tests/Adapter/AbstractAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Accompli\Chrono\Test;

use Accompli\Chrono\Adapter\AbstractAdapter;
use Accompli\Chrono\Process\ProcessExecutorInterface;
use PHPUnit_Framework_TestCase;

/**
Expand All @@ -18,9 +20,10 @@ public function testConstruct()
{
$repositoryUrl = 'https://github.com/accompli/chrono.git';
$repositoryDirectory = __DIR__;
$processExecutorMock = $this->getMockBuilder('Accompli\Chrono\Process\ProcessExecutorInterface')->getMock();
$processExecutorMock = $this->getMockBuilder(ProcessExecutorInterface::class)
->getMock();

$abstractAdapter = $this->getMockBuilder('Accompli\Chrono\Adapter\AbstractAdapter')
$abstractAdapter = $this->getMockBuilder(AbstractAdapter::class)
->setConstructorArgs(array($repositoryUrl, $repositoryDirectory, $processExecutorMock))
->getMockForAbstractClass();

Expand Down
26 changes: 13 additions & 13 deletions tests/Adapter/GitAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,31 +85,31 @@ public function provideTestSupportsRepository()
{
$provideTest = array();

$processExecutorMock = $this->getMockBuilder('Accompli\Chrono\Process\ProcessExecutorInterface')
$processExecutorMock = $this->getMockBuilder(ProcessExecutorInterface::class)
->getMock();
$processExecutorMock->expects($this->once())
->method('execute')
->with($this->equalTo('git --version'))
->willReturn(new ProcessExecutionResult(1, '', ''));
$provideTest[] = array('https://github.com/accompli/chrono.git', $processExecutorMock, false);

$processExecutorMock = $this->getMockBuilder('Accompli\Chrono\Process\ProcessExecutorInterface')
$processExecutorMock = $this->getMockBuilder(ProcessExecutorInterface::class)
->getMock();
$processExecutorMock->expects($this->once())
->method('execute')
->with($this->equalTo('git --version'))
->willReturn(new ProcessExecutionResult(0, '', ''));
$provideTest[] = array('https://github.com/accompli/chrono.git', $processExecutorMock, true);

$processExecutorMock = $this->getMockBuilder('Accompli\Chrono\Process\ProcessExecutorInterface')
$processExecutorMock = $this->getMockBuilder(ProcessExecutorInterface::class)
->getMock();
$processExecutorMock->expects($this->once())
->method('execute')
->with($this->equalTo('git --version'))
->willReturn(new ProcessExecutionResult(0, '', ''));
$provideTest[] = array('[email protected]:accompli/chrono.git', $processExecutorMock, true);

$processExecutorMock = $this->getMockBuilder('Accompli\Chrono\Process\ProcessExecutorInterface')
$processExecutorMock = $this->getMockBuilder(ProcessExecutorInterface::class)
->getMock();
$processExecutorMock->expects($this->exactly(2))
->method('execute')
Expand All @@ -123,7 +123,7 @@ public function provideTestSupportsRepository()
);
$provideTest[] = array('[email protected]:accompli/chrono', $processExecutorMock, true);

$processExecutorMock = $this->getMockBuilder('Accompli\Chrono\Process\ProcessExecutorInterface')
$processExecutorMock = $this->getMockBuilder(ProcessExecutorInterface::class)
->getMock();
$processExecutorMock->expects($this->exactly(2))
->method('execute')
Expand Down Expand Up @@ -151,15 +151,15 @@ public function provideTestGetBranches()

$provideTest = array();

$processExecutorMock = $this->getMockBuilder('Accompli\Chrono\Process\ProcessExecutorInterface')
$processExecutorMock = $this->getMockBuilder(ProcessExecutorInterface::class)
->getMock();
$processExecutorMock->expects($this->once())
->method('execute')
->with($this->equalTo($branchesCommand), $this->equalTo(null), $this->equalTo(array('GIT_TERMINAL_PROMPT' => '0', 'GIT_ASKPASS' => 'echo')))
->willReturn(new ProcessExecutionResult(1, '', ''));
$provideTest[] = array($processExecutorMock, array());

$processExecutorMock = $this->getMockBuilder('Accompli\Chrono\Process\ProcessExecutorInterface')
$processExecutorMock = $this->getMockBuilder(ProcessExecutorInterface::class)
->getMock();
$processExecutorMock->expects($this->once())
->method('execute')
Expand All @@ -181,15 +181,15 @@ public function provideTestGetTags()

$provideTest = array();

$processExecutorMock = $this->getMockBuilder('Accompli\Chrono\Process\ProcessExecutorInterface')
$processExecutorMock = $this->getMockBuilder(ProcessExecutorInterface::class)
->getMock();
$processExecutorMock->expects($this->once())
->method('execute')
->with($this->equalTo($tagsCommand), $this->equalTo(null), $this->equalTo(array('GIT_TERMINAL_PROMPT' => '0', 'GIT_ASKPASS' => 'echo')))
->willReturn(new ProcessExecutionResult(1, '', ''));
$provideTest[] = array($processExecutorMock, array());

$processExecutorMock = $this->getMockBuilder('Accompli\Chrono\Process\ProcessExecutorInterface')
$processExecutorMock = $this->getMockBuilder(ProcessExecutorInterface::class)
->getMock();
$processExecutorMock->expects($this->once())
->method('execute')
Expand All @@ -212,7 +212,7 @@ public function provideTestCheckout()

$provideTest = array();

$processExecutorMock = $this->getMockBuilder('Accompli\Chrono\Process\ProcessExecutorInterface')
$processExecutorMock = $this->getMockBuilder(ProcessExecutorInterface::class)
->getMock();
$processExecutorMock->expects($this->once())
->method('isDirectory')
Expand All @@ -223,7 +223,7 @@ public function provideTestCheckout()
->willReturn(new ProcessExecutionResult(1, '', ''));
$provideTest[] = array($processExecutorMock, false);

$processExecutorMock = $this->getMockBuilder('Accompli\Chrono\Process\ProcessExecutorInterface')
$processExecutorMock = $this->getMockBuilder(ProcessExecutorInterface::class)
->getMock();
$processExecutorMock->expects($this->once())
->method('isDirectory')
Expand All @@ -242,7 +242,7 @@ public function provideTestCheckout()
);
$provideTest[] = array($processExecutorMock, false);

$processExecutorMock = $this->getMockBuilder('Accompli\Chrono\Process\ProcessExecutorInterface')
$processExecutorMock = $this->getMockBuilder(ProcessExecutorInterface::class)
->getMock();
$processExecutorMock->expects($this->once())
->method('isDirectory')
Expand All @@ -253,7 +253,7 @@ public function provideTestCheckout()
->willReturn(new ProcessExecutionResult(0, '', ''));
$provideTest[] = array($processExecutorMock, true);

$processExecutorMock = $this->getMockBuilder('Accompli\Chrono\Process\ProcessExecutorInterface')
$processExecutorMock = $this->getMockBuilder(ProcessExecutorInterface::class)
->getMock();
$processExecutorMock->expects($this->once())
->method('isDirectory')
Expand Down
Loading

0 comments on commit 0583c20

Please sign in to comment.