Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#76] Moved functionality from Artifact class to ArtifactCommand class. #80

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
963 changes: 0 additions & 963 deletions src/Artifact.php

This file was deleted.

980 changes: 973 additions & 7 deletions src/Commands/ArtifactCommand.php

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions src/GitArtifactGitRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ public function removeBranch($name, bool $force = FALSE): GitArtifactGitReposito
return $this;
}

$branches = $this->getBranches();
if (empty($branches)) {
return $this;
}
if (!in_array($name, $branches)) {
return $this;
}

if (!$force) {
return parent::removeBranch($name);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/Functional/BranchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @group integration
*
* @covers \DrevOps\GitArtifact\GitTrait
* @covers \DrevOps\GitArtifact\Artifact
* @covers \DrevOps\GitArtifact\Commands\ArtifactCommand
* @covers \DrevOps\GitArtifact\FilesystemTrait
*/
class BranchTest extends AbstractFunctionalTestCase {
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/Functional/ForcePushTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*
* @covers \DrevOps\GitArtifact\GitTrait
* @covers \DrevOps\GitArtifact\Artifact
* @covers \DrevOps\GitArtifact\Commands\ArtifactCommand
* @covers \DrevOps\GitArtifact\FilesystemTrait
*/
class ForcePushTest extends AbstractFunctionalTestCase {
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/Functional/GeneralTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* @group integration
*
* @covers \DrevOps\GitArtifact\Artifact
* @covers \DrevOps\GitArtifact\Commands\ArtifactCommand
* @covers \DrevOps\GitArtifact\FilesystemTrait
*/
class GeneralTest extends AbstractFunctionalTestCase {
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/Functional/TagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @group integration
*
* @covers \DrevOps\GitArtifact\GitTrait
* @covers \DrevOps\GitArtifact\Artifact
* @covers \DrevOps\GitArtifact\Commands\ArtifactCommand
* @covers \DrevOps\GitArtifact\FilesystemTrait
*/
class TagTest extends AbstractFunctionalTestCase {
Expand Down
21 changes: 5 additions & 16 deletions tests/phpunit/Unit/AbstractUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,24 @@

namespace DrevOps\GitArtifact\Tests\Unit;

use DrevOps\GitArtifact\Artifact;
use DrevOps\GitArtifact\GitArtifactGit;
use DrevOps\GitArtifact\Commands\ArtifactCommand;
use DrevOps\GitArtifact\Tests\AbstractTestCase;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Filesystem\Filesystem;

/**
* Class AbstractUnitTestCase.
*/
abstract class AbstractUnitTestCase extends AbstractTestCase {

/**
* Mock of the class.
*
* @var \PHPUnit\Framework\MockObject\MockObject
* Artifact command.
*/
protected $mock;
protected ArtifactCommand $command;

protected function setUp(): void {
parent::setUp();

$mockBuilder = $this->getMockBuilder(Artifact::class);
$fileSystem = new Filesystem();
$gitWrapper = new GitArtifactGit();
$output = new ConsoleOutput();

$mockBuilder->setConstructorArgs([$gitWrapper, $fileSystem, $output]);
$this->mock = $mockBuilder->getMock();
$this->callProtectedMethod($this->mock, 'fsSetRootDir', [$this->fixtureDir]);
$this->command = new ArtifactCommand();
$this->callProtectedMethod($this->command, 'fsSetRootDir', [$this->fixtureDir]);
}

}
6 changes: 3 additions & 3 deletions tests/phpunit/Unit/ExcludeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* @group unit
*
* @covers \DrevOps\GitArtifact\Artifact
* @covers \DrevOps\GitArtifact\Commands\ArtifactCommand
*/
class ExcludeTest extends AbstractUnitTestCase {

Expand All @@ -19,7 +19,7 @@ class ExcludeTest extends AbstractUnitTestCase {
public function testExcludeExists(): void {
$this->createFixtureExcludeFile();

$actual = $this->callProtectedMethod($this->mock, 'localExcludeExists', [$this->fixtureDir]);
$actual = $this->callProtectedMethod($this->command, 'localExcludeExists', [$this->fixtureDir]);

$this->assertTrue($actual);
}
Expand All @@ -40,7 +40,7 @@ public function testExcludeExists(): void {
public function testExcludeEmpty(array $lines, bool $strict, bool $expected): void {
$this->createFixtureExcludeFile(implode(PHP_EOL, $lines));

$actual = $this->callProtectedMethod($this->mock, 'localExcludeEmpty', [$this->fixtureDir, $strict]);
$actual = $this->callProtectedMethod($this->command, 'localExcludeEmpty', [$this->fixtureDir, $strict]);

$this->assertEquals($expected, $actual);
}
Expand Down