2018-11-22 09:14:22 +01:00
|
|
|
<?php
|
|
|
|
|
2019-02-12 16:53:52 +01:00
|
|
|
namespace Tests\Integration\Entity\Source;
|
2018-11-22 09:14:22 +01:00
|
|
|
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
2020-04-02 21:13:35 +02:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2018-11-22 09:14:22 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This class tests if all needed Depencies for a source are implemented!
|
|
|
|
*
|
|
|
|
* @author kevinfrantz
|
|
|
|
*/
|
|
|
|
class SourceIntegrationTest extends TestCase
|
|
|
|
{
|
2019-02-12 16:53:52 +01:00
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
2019-02-12 16:55:57 +01:00
|
|
|
const SOURCE_DIRECTORY = __DIR__.'/../../../../src/Entity/Source';
|
2018-11-22 09:14:22 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var ArrayCollection
|
|
|
|
*/
|
|
|
|
protected $sources;
|
|
|
|
|
2019-02-12 16:52:27 +01:00
|
|
|
private function iterate(string $path): void
|
2018-11-22 09:14:22 +01:00
|
|
|
{
|
|
|
|
$directoryIterator = new \DirectoryIterator($path);
|
|
|
|
foreach ($directoryIterator as $fileInfo) {
|
|
|
|
if (!in_array($fileInfo->getFilename(), [
|
|
|
|
'.',
|
|
|
|
'..',
|
2019-02-12 16:52:27 +01:00
|
|
|
'README.md',
|
2018-11-22 09:14:22 +01:00
|
|
|
])) {
|
|
|
|
$pathname = $fileInfo->getPathname();
|
|
|
|
if ($fileInfo->isDir()) {
|
|
|
|
$this->iterate($pathname);
|
|
|
|
} elseif (false === strpos($pathname, 'Interface.php')) {
|
|
|
|
$this->sources->add(realpath($pathname));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-12 18:04:36 +01:00
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*
|
|
|
|
* @see \PHPUnit\Framework\TestCase::setUp()
|
|
|
|
*/
|
2018-11-22 09:14:22 +01:00
|
|
|
public function setUp(): void
|
|
|
|
{
|
|
|
|
$this->sources = new ArrayCollection();
|
|
|
|
$this->iterate(self::SOURCE_DIRECTORY);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function filterSourcePath(string $path): string
|
|
|
|
{
|
|
|
|
$path = str_replace('/Abstract', '/', $path);
|
|
|
|
$path = str_replace('.php', '', $path);
|
|
|
|
|
|
|
|
return $path;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getInterfacePath(string $path): string
|
|
|
|
{
|
|
|
|
return $this->filterSourcePath($path).'Interface.php';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testInterfaces(): void
|
|
|
|
{
|
|
|
|
foreach ($this->sources as $source) {
|
|
|
|
$interfacePath = $this->getInterfacePath($source);
|
|
|
|
$this->assertTrue(file_exists($this->getInterfacePath($source)), "Interface $interfacePath for $source doesn't exist!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|