mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-11-04 03:07:58 +00:00 
			
		
		
		
	Implemented PureSource
This commit is contained in:
		@@ -18,7 +18,7 @@ use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
 *
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
class DefaultController extends AbstractEntityController
 | 
			
		||||
final class DefaultController extends AbstractEntityController
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @todo Optimize function!
 | 
			
		||||
 
 | 
			
		||||
@@ -32,6 +32,7 @@ use App\Entity\Meta\Relation\Member\MemberRelationInterface;
 | 
			
		||||
 * @ORM\InheritanceType("JOINED")
 | 
			
		||||
 * @ORM\DiscriminatorColumn(name="discr", type="string")
 | 
			
		||||
 * @ORM\DiscriminatorMap({
 | 
			
		||||
 * "pure" = "PureSource",
 | 
			
		||||
 * "text" = "App\Entity\Source\Primitive\Text\TextSource",
 | 
			
		||||
 * "operation"="App\Entity\Source\Operation\AbstractOperation",
 | 
			
		||||
 * "user" = "App\Entity\Source\Complex\UserSource",
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										21
									
								
								application/src/Entity/Source/PureSource.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								application/src/Entity/Source/PureSource.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Entity\Source;
 | 
			
		||||
 | 
			
		||||
use Doctrine\ORM\Mapping as ORM;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This class represents a source with no additional attributes
 | 
			
		||||
 * Never inhiere from this!
 | 
			
		||||
 * Use instead AbstractSource!
 | 
			
		||||
 *
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 * @ORM\Entity
 | 
			
		||||
 */
 | 
			
		||||
class PureSource extends AbstractSource implements PureSourceInterface
 | 
			
		||||
{
 | 
			
		||||
    public function __construct()
 | 
			
		||||
    {
 | 
			
		||||
        parent::__construct();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										10
									
								
								application/src/Entity/Source/PureSourceInterface.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								application/src/Entity/Source/PureSourceInterface.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Entity\Source;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
interface PureSourceInterface extends SourceInterface
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,49 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace Integration\Entity\Source;
 | 
			
		||||
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
 | 
			
		||||
use App\Repository\Source\SourceRepository;
 | 
			
		||||
use App\Entity\Source\PureSourceInterface;
 | 
			
		||||
use App\Entity\Source\PureSource;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
class PureSourceIntegrationTest extends KernelTestCase
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var EntityManagerInterface
 | 
			
		||||
     */
 | 
			
		||||
    private $entityManager;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var SourceRepository
 | 
			
		||||
     */
 | 
			
		||||
    private $sourceRepository;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var PureSourceInterface
 | 
			
		||||
     */
 | 
			
		||||
    private $pureSource;
 | 
			
		||||
 | 
			
		||||
    public function setUp(): void
 | 
			
		||||
    {
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
        $this->entityManager = self::$container->get('doctrine.orm.default_entity_manager');
 | 
			
		||||
        $this->sourceRepository = $this->entityManager->getRepository(PureSource::class);
 | 
			
		||||
        $this->pureSource = new PureSource();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testDatabaseProcess(): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->entityManager->persist($this->pureSource);
 | 
			
		||||
        $this->entityManager->flush();
 | 
			
		||||
        $this->assertGreaterThan(0, $this->pureSource->getId());
 | 
			
		||||
        $this->entityManager->remove($this->pureSource);
 | 
			
		||||
        $this->entityManager->flush();
 | 
			
		||||
        $this->expectException(\TypeError::class);
 | 
			
		||||
        $this->pureSource->getId();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										36
									
								
								application/tests/Unit/Entity/Source/PureSourceTest.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								application/tests/Unit/Entity/Source/PureSourceTest.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace Tests\Unit\Entity\Source;
 | 
			
		||||
 | 
			
		||||
use App\Entity\Source\PureSourceInterface;
 | 
			
		||||
use App\Entity\Source\SourceInterface;
 | 
			
		||||
use App\Entity\Source\PureSource;
 | 
			
		||||
use App\Entity\Source\AbstractSource;
 | 
			
		||||
use PHPUnit\Framework\TestCase;
 | 
			
		||||
 | 
			
		||||
class PureSourceTest extends TestCase
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var PureSourceInterface
 | 
			
		||||
     */
 | 
			
		||||
    private $pureSource;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var SourceInterface
 | 
			
		||||
     */
 | 
			
		||||
    private $abstractSource;
 | 
			
		||||
 | 
			
		||||
    public function setUp(): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->pureSource = new PureSource();
 | 
			
		||||
        $this->abstractSource = new class() extends AbstractSource {
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testMethodSet(): void
 | 
			
		||||
    {
 | 
			
		||||
        $pureSourceMethods = get_class_methods($this->pureSource);
 | 
			
		||||
        $abstractSourceMethods = get_class_methods($this->abstractSource);
 | 
			
		||||
        $this->assertArraySubset($pureSourceMethods, $abstractSourceMethods);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user