Skip to content

Commit

Permalink
add test to verify that Application::VERSION match the latest git tag
Browse files Browse the repository at this point in the history
  • Loading branch information
llaville committed Jan 9, 2024
1 parent ab4058a commit 6b12352
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,11 @@ jobs:
run: composer update --optimize-autoloader --no-interaction --no-progress --prefer-dist ${{ matrix.composer-flags }}

- name: Run tests
if: github.ref_type == 'branch'
shell: bash
run: composer run test --exclude-group tags

- name: Run release tests
if: github.ref_type == 'tag'
shell: bash
run: composer run test
2 changes: 1 addition & 1 deletion src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class Application extends BaseApplication
{
public const VERSION = '3.3.0';
public const VERSION = '3.4.0';
private const NAME = 'phpmnd';

private Container $container;
Expand Down
43 changes: 43 additions & 0 deletions tests/Application/ApplicationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

declare(strict_types=1);

namespace Povils\PHPMND\Tests\Application;

use PHPUnit\Framework\TestCase;
use Povils\PHPMND\Console\Application;
use Povils\PHPMND\Container;
use SebastianBergmann\Version;
use Symfony\Component\Console\Tester\ApplicationTester;

/**
* @author Laurent Laville
* @group tags
* Allow to exclude this group from CI workflow when tag is not pushed
*/
class ApplicationTest extends TestCase
{
private ApplicationTester $applicationTester;
protected function setUp(): void
{
$application = new Application(Container::create());
$application->setAutoExit(false);

$this->applicationTester = new ApplicationTester($application);
}

public function testApplicationVersionInstalled(): void
{
$this->applicationTester->run(['--version', '--no-ansi']);

$installedVersion = \ltrim(
(new Version('', dirname(__DIR__, 2)))->getVersion(),
'-v'
);

$this->assertSame(
\sprintf('phpmnd version %s by Povilas Susinskas', $installedVersion),
\trim($this->applicationTester->getDisplay())
);
}
}

0 comments on commit 6b12352

Please sign in to comment.