Add test for all concordance lists implementing the concordance list
interface
This commit is contained in:
parent
0cd1d24a2a
commit
75f2538e16
64
tests/InterfaceImplementationTest.php
Normal file
64
tests/InterfaceImplementationTest.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Test to ensure that all concordance lists in this repository implement the MDImporterConcordanceListInterface interface.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
// Require autoloader as per MDImporter's provideEnv.php
|
||||
require_once __DIR__ . '/../../../provideEnv.php';
|
||||
|
||||
/**
|
||||
* Test to ensure that all concordance lists in this repository implement the MDImporterConcordanceListInterface interface.
|
||||
*/
|
||||
final class InterfaceImplementationTest extends TestCase {
|
||||
|
||||
/** @var string[] */
|
||||
private array $_lists = [];
|
||||
|
||||
/**
|
||||
* Quasi-constructor connects to DB.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp():void {
|
||||
|
||||
if (($listFiles = scandir(__DIR__ . '/../src')) === false) {
|
||||
throw new Exception("Failed to read /src directory");
|
||||
}
|
||||
|
||||
foreach ($listFiles as $file) {
|
||||
if (pathinfo($file, PATHINFO_EXTENSION) === 'php') {
|
||||
$this->_lists[] = pathinfo($file, PATHINFO_FILENAME);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test all concordance lists for their implementation of MDImporterConcordanceListInterface.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
* @group ValidOutput
|
||||
* @group HTMLOutput
|
||||
* @group SafeForProduction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testListInterfaceIsImplemented():void {
|
||||
|
||||
foreach ($this->_lists as $list) {
|
||||
if (!file_exists(__DIR__ . '/../src/' . $list . '.php')) {
|
||||
throw new Exception("List file does not exist" . $list);
|
||||
}
|
||||
require_once __DIR__ . '/../src/' . $list . '.php';
|
||||
|
||||
$interfaces = class_implements(new $list);
|
||||
self::assertArrayHasKey('MDImporterConcordanceListInterface', $interfaces);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user