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

Add test to verify that Application::VERSION match the latest git tag #175

Merged
merged 2 commits into from
Jan 14, 2024
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
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: vendor/bin/phpunit --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())
);
}
}
Loading