Added integration test for source

This commit is contained in:
Kevin Frantz 2018-11-22 09:14:22 +01:00
parent 11dc206575
commit c54ef4d2ca
4 changed files with 75 additions and 3 deletions

View File

@ -20,7 +20,7 @@
<testsuites> <testsuites>
<testsuite name="Integration Test Suite"> <testsuite name="Integration Test Suite">
<directory>./tests/integration/</directory> <directory>./tests/Integration/</directory>
</testsuite> </testsuite>
<testsuite name="Unit Test Suite"> <testsuite name="Unit Test Suite">
<directory>./tests/Unit/</directory> <directory>./tests/Unit/</directory>

View File

@ -2,7 +2,6 @@
namespace App\Entity\Source\Operation; namespace App\Entity\Source\Operation;
use App\Logic\Operation\OperandInterface;
use App\Logic\Result\Result; use App\Logic\Result\Result;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use App\Exception\NotDefinedException; use App\Exception\NotDefinedException;
@ -14,7 +13,7 @@ use App\Exception\NotDefinedException;
* *
* @todo move to the logic level! * @todo move to the logic level!
*/ */
class AndOperation extends AbstractOperation class AndOperation extends AbstractOperation implements AndOperationInterface
{ {
public function process(): void public function process(): void
{ {

View File

@ -0,0 +1,7 @@
<?php
namespace App\Entity\Source\Operation;
interface AndOperationInterface extends OperationInterface
{
}

View File

@ -0,0 +1,66 @@
<?php
namespace Tests\Integration;
use PHPUnit\Framework\TestCase;
use Doctrine\Common\Collections\ArrayCollection;
/**
* This class tests if all needed Depencies for a source are implemented!
*
* @author kevinfrantz
*/
class SourceIntegrationTest extends TestCase
{
const SOURCE_DIRECTORY = __DIR__.'/../../src/Entity/Source';
/**
* @var ArrayCollection
*/
protected $sources;
private function iterate(string $path)
{
$directoryIterator = new \DirectoryIterator($path);
foreach ($directoryIterator as $fileInfo) {
if (!in_array($fileInfo->getFilename(), [
'.',
'..',
])) {
$pathname = $fileInfo->getPathname();
if ($fileInfo->isDir()) {
$this->iterate($pathname);
} elseif (false === strpos($pathname, 'Interface.php')) {
$this->sources->add(realpath($pathname));
}
}
}
}
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!");
}
}
}