65 lines
1.8 KiB
PHP
65 lines
1.8 KiB
PHP
<?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);
|
|
}
|
|
|
|
}
|
|
}
|