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 3 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.

974 changes: 967 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
7 changes: 6 additions & 1 deletion src/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
*/

use DrevOps\GitArtifact\Commands\ArtifactCommand;
use DrevOps\GitArtifact\GitArtifactGit;
use Symfony\Component\Console\Application;
use Symfony\Component\Filesystem\Filesystem;

$application = new Application();

$command = new ArtifactCommand();
$git = new GitArtifactGit();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move this into the ArtifactCommand class

please do not modify this file - it is a standard entrypoint

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @AlexSkrypnyk
I have reverted to standard entry point.

$filesystem = new Filesystem();

$command = new ArtifactCommand($git, $filesystem);
$application->add($command);
$application->setDefaultCommand((string) $command->getName(), TRUE);

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
17 changes: 5 additions & 12 deletions tests/phpunit/Unit/AbstractUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

namespace DrevOps\GitArtifact\Tests\Unit;

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

/**
Expand All @@ -14,23 +13,17 @@
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($gitWrapper, $fileSystem);
$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