diff --git a/tests/Functional/Controller/Admin/AdminControllerTest.php b/tests/Functional/Controller/Admin/AdminControllerTest.php new file mode 100644 index 0000000..f1ef314 --- /dev/null +++ b/tests/Functional/Controller/Admin/AdminControllerTest.php @@ -0,0 +1,87 @@ +client = $this->createAuthenticatedClient(); + } + + /** + * @dataProvider loadFormKeys + */ + public function testFormMetadata(string $formKey): void + { + $this->client->request('GET', '/admin/metadata/form/' . $formKey); + + $this->assertHttpStatusCode(200, $this->client->getResponse()); + } + + /** + * @dataProvider loadListKeys + */ + public function testListMetadata(string $listKey): void + { + $this->client->request('GET', '/admin/metadata/list/' . $listKey); + + $this->assertHttpStatusCode(200, $this->client->getResponse()); + } + + public function testConfig(): void + { + $this->client->request('GET', '/admin/config'); + + $this->assertHttpStatusCode(200, $this->client->getResponse()); + } + + /** + * @return \Generator> + */ + public function loadFormKeys() + { + return $this->getFileKeys('forms'); + } + + /** + * @return \Generator> + */ + public function loadListKeys(): \Generator + { + return $this->getFileKeys('lists'); + } + + /** + * @return \Generator> + */ + private function getFileKeys(string $type): \Generator + { + $finder = new Finder(); + $path = __DIR__ . '/../../../../config/' . $type; + + $path = realpath($path); + if (!$path) { + throw new \RuntimeException(sprintf('Could not find path: "%s"', $path)); + } + + $finder->in($path); + + foreach ($finder as $file) { + yield [ + $file->getFilenameWithoutExtension(), + ]; + } + } +}