mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 06:01:35 +01:00
Added Text source
This commit is contained in:
parent
0ca2838ae2
commit
4066634af2
21
application/src/Entity/Attribut/TextAttribut.php
Normal file
21
application/src/Entity/Attribut/TextAttribut.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
trait TextAttribut
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $text;
|
||||
|
||||
public function getText(): string
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
public function setText(string $text): void
|
||||
{
|
||||
$this->text = $text;
|
||||
}
|
||||
}
|
10
application/src/Entity/Attribut/TextAttributInterface.php
Normal file
10
application/src/Entity/Attribut/TextAttributInterface.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
interface TextAttributInterface
|
||||
{
|
||||
public function getText(): string;
|
||||
|
||||
public function setText(string $text): void;
|
||||
}
|
@ -12,7 +12,7 @@ use App\Entity\Source\AbstractSource;
|
||||
* @ORM\Table(name="source_data")
|
||||
* @ORM\InheritanceType("JOINED")
|
||||
* @ORM\DiscriminatorColumn(name="discr", type="string")
|
||||
* @ORM\DiscriminatorMap({"name" = "App\Entity\Source\Primitive\Name\AbstractNameSource"})
|
||||
* @ORM\DiscriminatorMap({"name" = "App\Entity\Source\Primitive\Name\AbstractNameSource","text" = "App\Entity\Source\Primitive\Text\TextSource"})
|
||||
*/
|
||||
abstract class AbstractPrimitiveSource extends AbstractSource implements PrimitiveSourceInterface
|
||||
{
|
||||
|
23
application/src/Entity/Source/Primitive/Text/TextSource.php
Normal file
23
application/src/Entity/Source/Primitive/Text/TextSource.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Source\Primitive\Text;
|
||||
|
||||
use App\Entity\Source\Primitive\AbstractPrimitiveSource;
|
||||
use App\Entity\Attribut\TextAttribut;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
* @ORM\Entity
|
||||
*/
|
||||
class TextSource extends AbstractPrimitiveSource implements TextSourceInterface
|
||||
{
|
||||
use TextAttribut;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string")
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $text;
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Source\Primitive\Text;
|
||||
|
||||
use App\Entity\Source\Primitive\PrimitiveSourceInterface;
|
||||
use App\Entity\Attribut\TextAttributInterface;
|
||||
|
||||
interface TextSourceInterface extends PrimitiveSourceInterface, TextAttributInterface
|
||||
{
|
||||
}
|
38
application/tests/Unit/Entity/Attribut/TextAttributTest.php
Normal file
38
application/tests/Unit/Entity/Attribut/TextAttributTest.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\TextAttributInterface;
|
||||
use App\Entity\Attribut\TextAttribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class TextAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var TextAttributInterface
|
||||
*/
|
||||
protected $textAttribut;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->textAttribut = new class() implements TextAttributInterface {
|
||||
use TextAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->textAttribut->getText();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$text = 'Hello World!';
|
||||
$this->assertNull($this->textAttribut->setText($text));
|
||||
$this->assertEquals($text, $this->textAttribut->getText());
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Entity\Source\Primitive\Text;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Source\Primitive\Text\TextSourceInterface;
|
||||
use App\Entity\Source\Primitive\Text\TextSource;
|
||||
|
||||
class TextSourceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var TextSourceInterface
|
||||
*/
|
||||
protected $textSource;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->textSource = new TextSource();
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->textSource->getText();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user