mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-10-31 17:29:04 +00:00 
			
		
		
		
	Implemented test and logic for AbstractOperation
This commit is contained in:
		| @@ -0,0 +1,64 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Entity\Source\Operand; | ||||
|  | ||||
| use PHPUnit\Framework\TestCase; | ||||
| use App\Entity\Source\Operation\AbstractOperation; | ||||
| use App\Entity\Source\Operation\OperationInterface; | ||||
| use Doctrine\Common\Collections\Collection; | ||||
| use Doctrine\Common\Collections\ArrayCollection; | ||||
| use App\Logic\Operation\OperandInterface; | ||||
| use App\Logic\Result\ResultInterface; | ||||
| use App\Logic\Result\Result; | ||||
|  | ||||
| class AbstractOperationTest extends TestCase | ||||
| { | ||||
|     /** | ||||
|      * @var OperationInterface | ||||
|      */ | ||||
|     protected $operation; | ||||
|  | ||||
|     public function setUp(): void | ||||
|     { | ||||
|         $this->operation = new class() extends AbstractOperation { | ||||
|             public function getResult(): ResultInterface | ||||
|             { | ||||
|                 return new Result(); | ||||
|             } | ||||
|  | ||||
|             public function process(): void | ||||
|             { | ||||
|                 return; | ||||
|             } | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|     public function testConstructor(): void | ||||
|     { | ||||
|         $this->assertInstanceOf(Collection::class, $this->operation->getOperands()); | ||||
|     } | ||||
|  | ||||
|     public function testOperands(): void | ||||
|     { | ||||
|         $operand = new class() implements OperandInterface { | ||||
|             public function getResult(): ResultInterface | ||||
|             { | ||||
|                 return new Result(); | ||||
|             } | ||||
|         }; | ||||
|         $operands = new ArrayCollection(); | ||||
|         $operands->add($operand); | ||||
|         $this->operation->setOperands($operands); | ||||
|         $this->assertEquals($operand, $this->operation->getOperands()->get(0)); | ||||
|     } | ||||
|  | ||||
|     public function testResult() | ||||
|     { | ||||
|         $this->assertInstanceOf(ResultInterface::class, $this->operation->getResult()); | ||||
|     } | ||||
|  | ||||
|     public function testProcess(): void | ||||
|     { | ||||
|         $this->assertEquals(null, $this->operation->process()); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user