|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Docs Builder package. |
| 5 | + * (c) Ryan Weaver <[email protected]> |
| 6 | + * For the full copyright and license information, please view the LICENSE |
| 7 | + * file that was distributed with this source code. |
| 8 | + */ |
| 9 | + |
| 10 | +namespace SymfonyDocsBuilder\Tests; |
| 11 | + |
| 12 | +use SymfonyDocsBuilder\DocBuilder; |
| 13 | + |
| 14 | +class JsonIntegrationTest extends AbstractIntegrationTest |
| 15 | +{ |
| 16 | + /** |
| 17 | + * @dataProvider getJsonTests |
| 18 | + */ |
| 19 | + public function testJsonGeneration(string $filename, array $expectedData) |
| 20 | + { |
| 21 | + $buildConfig = $this->createBuildConfig(__DIR__ . '/fixtures/source/json'); |
| 22 | + $builder = new DocBuilder(); |
| 23 | + $buildResult = $builder->build($buildConfig); |
| 24 | + $fJsons = $buildResult->getJsonResults(); |
| 25 | + |
| 26 | + $actualFileData = $fJsons[$filename]; |
| 27 | + foreach ($expectedData as $key => $expectedKeyData) { |
| 28 | + $this->assertArrayHasKey($key, $actualFileData, sprintf('Missing key "%s" in file "%s"', $key, $filename)); |
| 29 | + $this->assertSame($expectedData[$key], $actualFileData[$key], sprintf('Invalid data for key "%s" in file "%s"', $key, $filename)); |
| 30 | + } |
| 31 | + } |
| 32 | + |
| 33 | + public function getJsonTests() |
| 34 | + { |
| 35 | + yield 'index' => [ |
| 36 | + 'file' => 'index', |
| 37 | + 'data' => [ |
| 38 | + //'parents' => [], |
| 39 | + 'prev' => null, |
| 40 | + 'next' => [ |
| 41 | + 'link' => 'dashboards/', |
| 42 | + 'title' => 'Dashboards' |
| 43 | + ], |
| 44 | + 'title' => 'JSON Generation Test', |
| 45 | + ] |
| 46 | + ]; |
| 47 | + |
| 48 | + yield 'dashboards' => [ |
| 49 | + 'file' => 'dashboards', |
| 50 | + 'data' => [ |
| 51 | + //'parents' => [], |
| 52 | + 'prev' => [ |
| 53 | + 'title' => 'JSON Generation Test', |
| 54 | + 'link' => 'index.html', |
| 55 | + ], |
| 56 | + 'next' => [ |
| 57 | + 'title' => 'CRUD', |
| 58 | + 'link' => 'crud.html', |
| 59 | + ], |
| 60 | + 'title' => 'Dashboards', |
| 61 | + ] |
| 62 | + ]; |
| 63 | + |
| 64 | + yield 'crud' => [ |
| 65 | + 'file' => 'crud', |
| 66 | + 'data' => [ |
| 67 | + //'parents' => [], |
| 68 | + 'prev' => [ |
| 69 | + 'title' => 'Dashboards', |
| 70 | + 'link' => 'dashboards.html', |
| 71 | + ], |
| 72 | + 'next' => [ |
| 73 | + 'title' => 'Design', |
| 74 | + 'link' => 'design.html', |
| 75 | + ], |
| 76 | + 'title' => 'CRUD', |
| 77 | + ] |
| 78 | + ]; |
| 79 | + |
| 80 | + yield 'design' => [ |
| 81 | + 'file' => 'design', |
| 82 | + 'data' => [ |
| 83 | + //'parents' => [], |
| 84 | + 'prev' => [ |
| 85 | + 'title' => 'CRUD', |
| 86 | + 'link' => 'crud.html', |
| 87 | + ], |
| 88 | + 'next' => null, |
| 89 | + 'title' => 'Design', |
| 90 | + ] |
| 91 | + ]; |
| 92 | + } |
| 93 | +} |
0 commit comments