mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-10-31 01:09:41 +00:00 
			
		
		
		
	Added integration test for source
This commit is contained in:
		| @@ -20,7 +20,7 @@ | ||||
|  | ||||
|     <testsuites> | ||||
|         <testsuite name="Integration Test Suite"> | ||||
|             <directory>./tests/integration/</directory> | ||||
|             <directory>./tests/Integration/</directory> | ||||
|         </testsuite> | ||||
|         <testsuite name="Unit Test Suite"> | ||||
|             <directory>./tests/Unit/</directory> | ||||
|   | ||||
| @@ -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 | ||||
|     { | ||||
|   | ||||
| @@ -0,0 +1,7 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Entity\Source\Operation; | ||||
|  | ||||
| interface AndOperationInterface extends OperationInterface | ||||
| { | ||||
| } | ||||
							
								
								
									
										66
									
								
								application/tests/Integration/SourceIntegrationTest.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								application/tests/Integration/SourceIntegrationTest.php
									
									
									
									
									
										Normal 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!"); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user