1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Tests\Command;
use PhpMyAdmin\Command\WriteGitRevisionCommand;
use PhpMyAdmin\Tests\AbstractTestCase;
use Symfony\Component\Console\Command\Command;
use function class_exists;
use function sprintf;
/**
* @covers \PhpMyAdmin\Command\WriteGitRevisionCommand
*/
class WriteGitRevisionCommandTest extends AbstractTestCase
{
/** @var WriteGitRevisionCommand */
private $command;
public function testGetGeneratedClassValidVersion(): void
{
if (! class_exists(Command::class)) {
$this->markTestSkipped('The Symfony Console is missing');
}
$this->command = $this->getMockBuilder(WriteGitRevisionCommand::class)
->onlyMethods(['gitCli'])
->getMock();
$this->command->expects($this->exactly(3))
->method('gitCli')
->withConsecutive(
['describe --always'],
['log -1 --format="%H"'],
['symbolic-ref -q HEAD']
)
->willReturnOnConsecutiveCalls(
'RELEASE_5_1_0-638-g1c018e2a6c',
'1c018e2a6c6d518c4a2dde059e49f33af67c4636',
'refs/heads/cli-rev-info'
);
$output = $this->callFunction(
$this->command,
WriteGitRevisionCommand::class,
'getRevisionInfo',
[
'https://github.com/phpmyadmin/phpmyadmin/commit/%s',
'https://github.com/phpmyadmin/phpmyadmin/tree/%s',
]
);
$template = <<<'PHP'
<?php
declare(strict_types=1);
/**
* This file is generated by scripts/console.
*
* @see \PhpMyAdmin\Command\WriteGitRevisionCommand
*/
return [
'revision' => '%s',
'revisionUrl' => '%s',
'branch' => '%s',
'branchUrl' => '%s',
];
PHP;
$this->assertSame(
sprintf(
$template,
'RELEASE_5_1_0-638-g1c018e2a6c',
'https://github.com/phpmyadmin/phpmyadmin/commit/1c018e2a6c6d518c4a2dde059e49f33af67c4636',
'cli-rev-info',
'https://github.com/phpmyadmin/phpmyadmin/tree/cli-rev-info'
),
$output
);
}
}
|