* Fix wrong type hint Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use $this instead of parent Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * setUp should be a protected method Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * onNotSuccessfulTest should be protected Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * $command doesn't need to be a property Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Give alertText() proper return type Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use null-safe operator Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Call Message static constructors statically Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Call StorageEngine methods statically Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Add better type hints in PrivilegesController Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use packed (without keys) arrays in tests Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use type casts instead of function casts Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use const instead of private property Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use const instead of private property Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Fix testAuthFailsTooLongPass() Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Replace loop with array_shift Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use ob_get_clean Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Remove duplicated code Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use assert instead of phpdoc Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> --------- Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
70 lines
1.9 KiB
PHP
70 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpMyAdmin\Tests\Command;
|
|
|
|
use PhpMyAdmin\Command\WriteGitRevisionCommand;
|
|
use PhpMyAdmin\Tests\AbstractTestCase;
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
use Symfony\Component\Console\Command\Command;
|
|
|
|
use function class_exists;
|
|
use function sprintf;
|
|
|
|
#[CoversClass(WriteGitRevisionCommand::class)]
|
|
class WriteGitRevisionCommandTest extends AbstractTestCase
|
|
{
|
|
public function testGetGeneratedClassValidVersion(): void
|
|
{
|
|
if (! class_exists(Command::class)) {
|
|
self::markTestSkipped('The Symfony Console is missing');
|
|
}
|
|
|
|
$command = $this->getMockBuilder(WriteGitRevisionCommand::class)
|
|
->onlyMethods(['gitCli'])
|
|
->getMock();
|
|
|
|
$command->expects(self::exactly(3))->method('gitCli')->willReturnMap([
|
|
['describe --always', 'RELEASE_5_1_0-638-g1c018e2a6c'],
|
|
['log -1 --format="%H"', '1c018e2a6c6d518c4a2dde059e49f33af67c4636'],
|
|
['symbolic-ref -q HEAD', 'refs/heads/cli-rev-info'],
|
|
]);
|
|
|
|
$output = $this->callFunction(
|
|
$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 bin/console.
|
|
*
|
|
* @see \PhpMyAdmin\Command\WriteGitRevisionCommand
|
|
*/
|
|
return [
|
|
'revision' => '%s',
|
|
'revisionUrl' => '%s',
|
|
'branch' => '%s',
|
|
'branchUrl' => '%s',
|
|
];
|
|
|
|
PHP;
|
|
self::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,
|
|
);
|
|
}
|
|
}
|