Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
tannguyen04 committed Mar 15, 2024
1 parent 58e902f commit 2609ced
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 49 deletions.
28 changes: 14 additions & 14 deletions src/Artifact.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,37 +47,37 @@ class Artifact {
/**
* Original branch in current repository.
*
* @var string
* @var string|null
*/
protected string $originalBranch;
protected ?string $originalBranch = NULL;

/**
* Destination branch with optional tokens.
*
* @var string
* @var string|null
*/
protected string $destinationBranch;
protected ?string $destinationBranch = NULL;

/**
* Local branch where artifact will be built.
*
* @var string
* @var string|null
*/
protected string $artifactBranch;
protected ?string $artifactBranch = NULL;

/**
* Remote name.
*
* @var string
* @var string|null
*/
protected string $remoteName;
protected ?string $remoteName = NULL;

/**
* Remote URL includes uri or local path.
*
* @var string
* @var string|null
*/
protected string $remoteUrl;
protected ?string $remoteUrl = NULL;

/**
* Gitignore file to be used during artifact creation.
Expand All @@ -91,23 +91,23 @@ class Artifact {
/**
* Commit message with optional tokens.
*
* @var string
* @var string|null
*/
protected string $message;
protected ?string $message = NULL;

/**
* Flag to specify if push is required or should be using dry run.
*
* @var bool
*/
protected bool $needsPush;
protected bool $needsPush = FALSE;

/**
* Flag to specify if cleanup is required to run after the build.
*
* @var bool
*/
protected bool $needCleanup;
protected bool $needCleanup = TRUE;

/**
* Path to report file.
Expand Down
34 changes: 1 addition & 33 deletions src/GitArtifactGitRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Symfony\Component\Filesystem\Filesystem;

/**
*
* Artifact git repository.
*/
class GitArtifactGitRepository extends GitRepository {

Expand Down Expand Up @@ -126,38 +126,6 @@ public function removeRemote($name): GitArtifactGitRepository {
return $this;
}

/**
* Get remote list.
*
* @return array<string>|null
* Remotes.
*
* @throws \CzProject\GitPhp\GitException
*/
public function getRemotes(): ?array {
return $this->extractFromCommand(['remote']);
}

/**
* Check remote is existing or not by remote name.
*
* @param string $remoteName
* Remote name to check.
*
* @return bool
* Exist or not.
*
* @throws \CzProject\GitPhp\GitException
*/
public function isRemoteExists(string $remoteName): bool {
$remotes = $this->getRemotes();
if (empty($remotes)) {
return FALSE;
}

return in_array($remoteName, $remotes);
}

/**
* Check if provided location is a URI.
*
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/Functional/GeneralTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public function testCompulsoryParameter(): void {
public function testInfo(): void {
$this->gitCreateFixtureCommits(1);
$output = $this->runBuild();

$this->assertStringContainsString('Artifact information', $output);
$this->assertStringContainsString('Mode: force-push', $output);
$this->assertStringContainsString('Source repository: ' . $this->src, $output);
Expand Down
3 changes: 2 additions & 1 deletion tests/phpunit/Unit/AbstractUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace DrevOps\GitArtifact\Tests\Unit;

use DrevOps\GitArtifact\Artifact;
use DrevOps\GitArtifact\GitArtifactGit;
use DrevOps\GitArtifact\Tests\AbstractTestCase;
use GitWrapper\GitWrapper;
use Symfony\Component\Console\Output\ConsoleOutput;
Expand All @@ -25,7 +26,7 @@ protected function setUp(): void {

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

$mockBuilder->setConstructorArgs([$gitWrapper, $fileSystem, $output]);
Expand Down

0 comments on commit 2609ced

Please sign in to comment.