Skip to content

Commit

Permalink
Merge pull request #144 from flavioheleno/fix/examples
Browse files Browse the repository at this point in the history
Fix broken examples
  • Loading branch information
rosstuck committed Oct 23, 2020
2 parents 8475c82 + f90b109 commit 3424d88
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 1 deletion.
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -20,7 +20,8 @@
"phpstan/extension-installer": "^1.0",
"squizlabs/php_codesniffer": "^3.5",
"doctrine/coding-standard": "^8.1",
"roave/security-advisories": "dev-latest"
"roave/security-advisories": "dev-latest",
"league/container": "^3.3"
},
"autoload": {
"psr-4": {
Expand Down
67 changes: 67 additions & 0 deletions tests/ExamplesTest.php
@@ -0,0 +1,67 @@
<?php

declare(strict_types=1);

namespace League\Tactician\Tests;

use PHPUnit\Framework\TestCase;

class ExamplesTest extends TestCase
{
/**
* @dataProvider exampleFiles
* @param string[] $expect
*/
public function testExample(string $file, array $expect) : void
{
// executes the example script using the php binary
exec(
implode(
' ',
[
'/usr/bin/env',
'php',
'-f',
escapeshellarg(__DIR__ . "/../examples/{$file}")
]
),
$output,
$exitCode
);

self::assertSame(0, $exitCode);
self::assertSame($expect, $output);
}

/**
* @return array<int, array<int, array<int, string>|string>>
*/
public function exampleFiles() : array
{
return [
[
'1-beginner-standard-usage.php',
['User alice@example.com was registered!']
],
[
'2-intermediate-create-middleware.php',
[
'LOG: Starting RegisterUser',
'User alice@example.com was registered!',
'LOG: RegisterUser finished without errors'
]
],
[
'3-intermediate-custom-naming-conventions.php',
['See, Tactician now calls the handle method we prefer!']
],
[
'4-conditional-handlers.php',
[
'Dispatched MyExternalCommand!',
'User alice@example.com was registered!'
]
]
];
}
}

0 comments on commit 3424d88

Please sign in to comment.