Skip to content

Commit 7029339

Browse files
author
Alexander Obuhovich
committed
Adding basic "Repository\Command" class test
1 parent 3a9b465 commit 7029339

File tree

2 files changed

+89
-6
lines changed

2 files changed

+89
-6
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
/**
3+
* This file is part of the SVN-Buddy library.
4+
* For the full copyright and license information, please view
5+
* the LICENSE file that was distributed with this source code.
6+
*
7+
* @copyright Alexander Obuhovich <aik.bold@gmail.com>
8+
* @link https://github.com/aik099/svn-buddy
9+
*/
10+
11+
namespace Tests\aik099\SVNBuddy\Repository\Connector;
12+
13+
14+
use aik099\SVNBuddy\Repository\Connector\Command;
15+
use Prophecy\Prophecy\ObjectProphecy;
16+
17+
class CommandTest extends \PHPUnit_Framework_TestCase
18+
{
19+
20+
/**
21+
* Process.
22+
*
23+
* @var ObjectProphecy
24+
*/
25+
private $_process;
26+
27+
/**
28+
* Console IO.
29+
*
30+
* @var ObjectProphecy
31+
*/
32+
private $_io;
33+
34+
/**
35+
* Cache manager.
36+
*
37+
* @var ObjectProphecy
38+
*/
39+
private $_cacheManager;
40+
41+
/**
42+
* Command.
43+
*
44+
* @var Command
45+
*/
46+
private $_command;
47+
48+
protected function setUp()
49+
{
50+
parent::setUp();
51+
52+
$this->_process = $this->prophesize('Symfony\\Component\\Process\\Process');
53+
$this->_io = $this->prophesize('aik099\\SVNBuddy\\ConsoleIO');
54+
$this->_cacheManager = $this->prophesize('aik099\\SVNBuddy\\Cache\\CacheManager');
55+
56+
$this->_command = $this->_createCommand();
57+
}
58+
59+
public function testRunWithoutCallback()
60+
{
61+
$this->_process->getCommandLine()->willReturn('svn log --limit 5')->shouldBeCalled();
62+
$this->_process->setInput('')->shouldBeCalled();
63+
$this->_process->mustRun(null)->shouldBeCalled();
64+
$this->_process->getOutput()->willReturn('OK')->shouldBeCalled();
65+
66+
$this->_io->isVerbose()->willReturn(false);
67+
68+
$this->_process
69+
->setCommandLine('svn --non-interactive log --limit 5')
70+
->will(function ($args, $process) {
71+
$process->getCommandLine()->willReturn($args[0])->shouldBeCalled();
72+
})
73+
->shouldBeCalled();
74+
75+
$this->assertEquals('OK', $this->_command->run());
76+
}
77+
78+
/**
79+
* Creates command.
80+
*
81+
* @return Command
82+
*/
83+
private function _createCommand()
84+
{
85+
return new Command($this->_process->reveal(), $this->_io->reveal(), $this->_cacheManager->reveal());
86+
}
87+
88+
}

tests/SVNBuddy/Repository/Connector/ConnectorTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ConnectorTest extends WorkingDirectoryAwareTestCase
4545
/**
4646
* Console IO.
4747
*
48-
* @var ConsoleIO
48+
* @var ObjectProphecy
4949
*/
5050
private $_io;
5151

@@ -63,11 +63,6 @@ class ConnectorTest extends WorkingDirectoryAwareTestCase
6363
*/
6464
private $_repositoryConnector;
6565

66-
/**
67-
* Prepares fixture.
68-
*
69-
* @return void
70-
*/
7166
protected function setUp()
7267
{
7368
parent::setUp();

0 commit comments

Comments
 (0)