ref: 99ff1413ff9b62e63f729594a2590d095526476c
converter/server/vendor/rybakit/msgpack/tests/ExamplesTest.php
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 |
<?php /* * This file is part of the rybakit/msgpack.php package. * * (c) Eugene Leonovich <gen.work@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace MessagePack\Tests; use PHPUnit\Framework\TestCase; final class ExamplesTest extends TestCase { /** * @dataProvider provideExampleData */ public function testExample(string $filename) : void { exec("php $filename", $output, $exitCode); self::assertSame(0, $exitCode); if ($output) { self::assertOutput($filename, implode("\n", $output)); } } public function provideExampleData() : iterable { $dir = dirname(__DIR__).'/examples'; foreach (glob("$dir/*.php") as $filename) { if (strpos($filename, 'autoload.php')) { continue; } yield [$filename]; } } private static function assertOutput(string $filename, string $output) : void { $content = file_get_contents($filename); if (preg_match('~\/\*\s*?OUTPUT\b(.+?)\*\/~s', $content, $matches)) { self::assertSame(trim($matches[1]), $output); } } } |