From c54ef4d2cadec6dbb5ac7b3b38115b1c8b68d78d Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Thu, 22 Nov 2018 09:14:22 +0100 Subject: [PATCH] Added integration test for source --- application/phpunit.xml.dist | 2 +- .../Entity/Source/Operation/AndOperation.php | 3 +- .../Operation/AndOperationInterface.php | 7 ++ .../Integration/SourceIntegrationTest.php | 66 +++++++++++++++++++ 4 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 application/src/Entity/Source/Operation/AndOperationInterface.php create mode 100644 application/tests/Integration/SourceIntegrationTest.php diff --git a/application/phpunit.xml.dist b/application/phpunit.xml.dist index fc15553..3aa35c8 100644 --- a/application/phpunit.xml.dist +++ b/application/phpunit.xml.dist @@ -20,7 +20,7 @@ - ./tests/integration/ + ./tests/Integration/ ./tests/Unit/ diff --git a/application/src/Entity/Source/Operation/AndOperation.php b/application/src/Entity/Source/Operation/AndOperation.php index 523d7dd..7268bf0 100644 --- a/application/src/Entity/Source/Operation/AndOperation.php +++ b/application/src/Entity/Source/Operation/AndOperation.php @@ -2,7 +2,6 @@ namespace App\Entity\Source\Operation; -use App\Logic\Operation\OperandInterface; use App\Logic\Result\Result; use Doctrine\ORM\Mapping as ORM; use App\Exception\NotDefinedException; @@ -14,7 +13,7 @@ use App\Exception\NotDefinedException; * * @todo move to the logic level! */ -class AndOperation extends AbstractOperation +class AndOperation extends AbstractOperation implements AndOperationInterface { public function process(): void { diff --git a/application/src/Entity/Source/Operation/AndOperationInterface.php b/application/src/Entity/Source/Operation/AndOperationInterface.php new file mode 100644 index 0000000..6692a9c --- /dev/null +++ b/application/src/Entity/Source/Operation/AndOperationInterface.php @@ -0,0 +1,7 @@ +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!"); + } + } +}