-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add AdminControllerTest to check form configurations and list configu…
…rtions (#29)
- Loading branch information
1 parent
49270bf
commit 0643747
Showing
1 changed file
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Tests\Functional\Controller\Admin; | ||
|
||
use Sulu\Bundle\TestBundle\Testing\SuluTestCase; | ||
use Symfony\Bundle\FrameworkBundle\KernelBrowser; | ||
use Symfony\Component\Finder\Finder; | ||
|
||
class AdminControllerTest extends SuluTestCase | ||
{ | ||
/** | ||
* @var KernelBrowser | ||
*/ | ||
private $client; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->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<array<string>> | ||
*/ | ||
public function loadFormKeys() | ||
{ | ||
return $this->getFileKeys('forms'); | ||
} | ||
|
||
/** | ||
* @return \Generator<array<string>> | ||
*/ | ||
public function loadListKeys(): \Generator | ||
{ | ||
return $this->getFileKeys('lists'); | ||
} | ||
|
||
/** | ||
* @return \Generator<array<string>> | ||
*/ | ||
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(), | ||
]; | ||
} | ||
} | ||
} |