getMockBuilder(WriteGitRevisionCommand::class) ->onlyMethods(['gitCli']) ->getMock(); $commitBody = implode("\n", [ 'tree 6857f00bb50360825c7df2c40ad21006c30beca7', 'parent 1634264816449dc42d17872174f3e8d73d4e36b2', 'author John Doe 1734427284', 'committer Hosted Weblate 1734516032', '', 'Translated using Weblate (Finnish)', '', 'Currently translated at 61.4% (2105 of 3428 strings)', '', '[ci skip]', '', 'Translation: phpMyAdmin/5.2', 'Translate-URL: https://hosted.weblate.org/projects/phpmyadmin/5-2/fi/', 'Signed-off-by: John Doe ', '', ]); $command->expects(self::exactly(4)) ->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'], [ 'show -s --pretty="tree %T%nparent %P%nauthor %an <%ae> %at' . '%ncommitter %cn <%ce> %ct%n%n%B"', $commitBody, ], ], ); $output = (new ReflectionMethod(WriteGitRevisionCommand::class, 'getRevisionInfo'))->invokeArgs($command, [ 'https://github.com/phpmyadmin/phpmyadmin/commit/%s', 'https://github.com/phpmyadmin/phpmyadmin/tree/%s', ]); $template = <<<'PHP' '%s', 'revisionHash' => '%s', 'revisionUrl' => '%s', 'branch' => '%s', 'branchUrl' => '%s', 'message' => '%s', 'author' => [ 'name' => '%s', 'email' => '%s', 'date' => '%s', ], 'committer' => [ 'name' => '%s', 'email' => '%s', 'date' => '%s', ], ]; PHP; self::assertSame(sprintf( $template, 'RELEASE_5_1_0-638-g1c018e2a6c', '1c018e2a6c6d518c4a2dde059e49f33af67c4636', 'https://github.com/phpmyadmin/phpmyadmin/commit/1c018e2a6c6d518c4a2dde059e49f33af67c4636', 'cli-rev-info', 'https://github.com/phpmyadmin/phpmyadmin/tree/cli-rev-info', 'Translated using Weblate (Finnish) ' . ' Currently translated at 61.4% (2105 of 3428 strings) ' . ' [ci skip] Translation: phpMyAdmin/5.2 ' . 'Translate-URL: https://hosted.weblate.org/projects/phpmyadmin/5-2/fi/' . ' Signed-off-by: John Doe ', // Commit message 'John Doe', // Author name 'john.doe@example.org', // Author email '2024-12-17 09:21:24 +0000', // Author date 'Hosted Weblate', // Committer name 'hosted@weblate.org', // Committer email '2024-12-18 10:00:32 +0000', // Committer date ), $output); } }