forked from AOEpeople/Tagging
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] RS-1988 : aoe/tagging library branch switching hinzufügen
wenn beim Aufruf des tagging scripts die Option '--switch-branch' zusammen mit einem Branch angegeben wird, wird innerhalb des Respository auf diesen Branch gewechselt
- Loading branch information
michael.sandritter
committed
Sep 8, 2016
1 parent
5580329
commit 603272f
Showing
6 changed files
with
298 additions
and
66 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
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 |
---|---|---|
|
@@ -2,14 +2,16 @@ | |
namespace AOE\Tagging\Tests\Command; | ||
|
||
use AOE\Tagging\Command\GitCommand; | ||
use AOE\Tagging\Tests\TaggingPHPUnitTestCase; | ||
use AOE\Tagging\Vcs\Driver\GitDriver; | ||
use Symfony\Component\Console\Application; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Tester\CommandTester; | ||
|
||
/** | ||
* @package AOE\Tagging\Tests\Vcs | ||
*/ | ||
class GitCommandTest extends \PHPUnit_Framework_TestCase | ||
class GitCommandTest extends TaggingPHPUnitTestCase | ||
{ | ||
/** | ||
* @test | ||
|
@@ -293,6 +295,43 @@ public function shouldCommitAdditionalFileWithMessage() | |
); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldWriteCommitAndPushInfoWithVerbosityVerbose() | ||
{ | ||
$gitDriver = $this->getMockBuilder('AOE\\Tagging\\Vcs\\Driver\\GitDriver') | ||
->disableOriginalConstructor() | ||
->setMethods(array('getLatestTag', 'tag', 'hasChangesSinceTag', 'commit')) | ||
->getMock(); | ||
$gitDriver->expects($this->once())->method('hasChangesSinceTag')->will($this->returnValue(true)); | ||
$gitDriver->expects($this->once())->method('getLatestTag')->will($this->returnValue('2.7.3')); | ||
$gitDriver->expects($this->once())->method('commit') | ||
->with(array('myfile.ext'), '/home/foo/bar', 'my message for commit'); | ||
$gitCommand = $this->getMockBuilder('AOE\\Tagging\\Command\\GitCommand') | ||
->setMethods(array('getDriver')) | ||
->getMock(); | ||
$gitCommand->expects($this->once())->method('getDriver')->will($this->returnValue($gitDriver)); | ||
|
||
/** @var GitCommand $gitCommand */ | ||
$application = new Application(); | ||
$application->add($gitCommand); | ||
|
||
$command = $application->find('git'); | ||
$commandTester = new CommandTester($command); | ||
$test = $commandTester->getOutput(); | ||
$commandTester->execute( | ||
array( | ||
'command' => $command->getName(), | ||
'url' => '[email protected]/foo/bar', | ||
'path' => '/home/foo/bar', | ||
'--commit-and-push' => array('myfile.ext'), | ||
'--message' => 'my message for commit' | ||
), | ||
['verbosity' => 2] | ||
); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
|
@@ -375,4 +414,47 @@ public function shouldEvaluateVersionNumberIfNoChangesDetected() | |
|
||
$this->assertEmpty($commandTester->getDisplay()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldCheckoutBranchWithSwitchBranchOptionWhenExecuting() | ||
{ | ||
$gitDriver = $this->getMockBuilder('AOE\\Tagging\\Vcs\\Driver\\GitDriver') | ||
->disableOriginalConstructor() | ||
->setMethods(array('checkoutBranch')) | ||
->getMock(); | ||
|
||
$gitDriver->expects($this->once())->method('checkoutBranch'); | ||
|
||
$gitCommand = $this->getMockBuilder('AOE\\Tagging\\Command\\GitCommand') | ||
->setMethods(array('getDriver')) | ||
->getMock(); | ||
$gitCommand->expects($this->once())->method('getDriver')->will($this->returnValue($gitDriver)); | ||
|
||
/** @var GitCommand $gitCommand */ | ||
$application = new Application(); | ||
$application->add($gitCommand); | ||
|
||
$command = $application->find('git'); | ||
$commandTester = new CommandTester($command); | ||
$commandTester->execute( | ||
array( | ||
'command' => $command->getName(), | ||
'url' => '[email protected]/foo/bar', | ||
'path' => '/home/foo/bar', | ||
'--switch-branch' => null | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetDriver() | ||
{ | ||
$gitCommand = new GitCommand(); | ||
$driver = $this->invokeMethod($gitCommand, 'getDriver',['https://url']); | ||
$this->assertInstanceOf(GitDriver::class, $driver); | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
namespace AOE\Tagging\Tests; | ||
|
||
class TaggingPHPUnitTestCase extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* Call protected/private method of a class. | ||
* | ||
* @param object &$object Instantiated object that we will run method on. | ||
* @param string $methodName Method name to call | ||
* @param array $parameters Array of parameters to pass into method. | ||
* | ||
* @return mixed Method return. | ||
*/ | ||
protected function invokeMethod(&$object, $methodName, array $parameters = array()) | ||
{ | ||
$reflection = new \ReflectionClass(get_class($object)); | ||
$method = $reflection->getMethod($methodName); | ||
$method->setAccessible(true); | ||
|
||
return $method->invokeArgs($object, $parameters); | ||
} | ||
} |
Oops, something went wrong.