From b73dc08d74efe3ef097c3ff5022ef279295bdec6 Mon Sep 17 00:00:00 2001 From: Paul VM Date: Fri, 19 Dec 2014 16:30:24 +0000 Subject: [PATCH] [#SDV-32] Introduced a new object for the Action Log. Refactored the SystemType attribute on the OutgoingDocument into an interface/trait because ActionLog needed it, too. --- .../Core/Model/Entity/Document/ActionLog.php | 33 ++++++++++++++++ .../Document/Decorators/HasSystemType.php | 17 ++++++++ .../Entity/Document/Decorators/SystemType.php | 37 ++++++++++++++++++ .../Core/Model/Entity/Document/Document.php | 1 + .../Entity/Document/OutgoingDocument.php | 32 ++------------- .../Model/Entity/Document/ActionLogTest.php | 21 ++++++++++ .../Document/Decorators/SystemTypeTest.php | 39 +++++++++++++++++++ 7 files changed, 152 insertions(+), 28 deletions(-) create mode 100644 src/Opg/Core/Model/Entity/Document/ActionLog.php create mode 100644 src/Opg/Core/Model/Entity/Document/Decorators/HasSystemType.php create mode 100644 src/Opg/Core/Model/Entity/Document/Decorators/SystemType.php create mode 100644 tests/OpgTest/Core/Model/Entity/Document/ActionLogTest.php create mode 100644 tests/OpgTest/Core/Model/Entity/Document/Decorators/SystemTypeTest.php diff --git a/src/Opg/Core/Model/Entity/Document/ActionLog.php b/src/Opg/Core/Model/Entity/Document/ActionLog.php new file mode 100644 index 00000000..c5ee3174 --- /dev/null +++ b/src/Opg/Core/Model/Entity/Document/ActionLog.php @@ -0,0 +1,33 @@ +systemType = $systemType; + + return $this; + } + + /** + * @return string + */ + public function getSystemType() + { + return $this->systemType; + } +} diff --git a/src/Opg/Core/Model/Entity/Document/Document.php b/src/Opg/Core/Model/Entity/Document/Document.php index bb1b805f..463133bd 100644 --- a/src/Opg/Core/Model/Entity/Document/Document.php +++ b/src/Opg/Core/Model/Entity/Document/Document.php @@ -34,6 +34,7 @@ * "incoming_document" = "Opg\Core\Model\Entity\Document\IncomingDocument", * "outgoing_document" = "Opg\Core\Model\Entity\Document\OutgoingDocument", * "lodging_checklist" = "Opg\Core\Model\Entity\Document\LodgingChecklist", + * "action_log" = "Opg\Core\Model\Entity\Document\ActionLog", * "annual_report" = "Opg\Core\Model\Entity\Document\AnnualReport", * }) * diff --git a/src/Opg/Core/Model/Entity/Document/OutgoingDocument.php b/src/Opg/Core/Model/Entity/Document/OutgoingDocument.php index 9a0bcfd9..f8503263 100644 --- a/src/Opg/Core/Model/Entity/Document/OutgoingDocument.php +++ b/src/Opg/Core/Model/Entity/Document/OutgoingDocument.php @@ -8,6 +8,8 @@ use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\ReadOnly; use Opg\Common\Model\Entity\DateFormat as OPGDateFormat; +use Opg\Core\Model\Entity\Document\Decorators\HasSystemType; +use Opg\Core\Model\Entity\Document\Decorators\SystemType; /** * @ORM\Entity @@ -16,13 +18,9 @@ * Class Correspondence * @package Opg\Core\Model\Entity\Document */ -class OutgoingDocument extends Document +class OutgoingDocument extends Document implements HasSystemType { - /** - * @ORM\Column(type = "string", nullable = true) - * @var string - */ - protected $systemType; + use SystemType; /** * @Type("string") @@ -36,26 +34,4 @@ public function __construct() { $this->createdDate = new \DateTime(); } - - - - /** - * @param string $systemType - * @return OutgoingDocument - */ - public function setSystemType($systemType) - { - $this->systemType = $systemType; - - return $this; - } - - /** - * @return string - */ - public function getSystemType() - { - return $this->systemType; - } - } diff --git a/tests/OpgTest/Core/Model/Entity/Document/ActionLogTest.php b/tests/OpgTest/Core/Model/Entity/Document/ActionLogTest.php new file mode 100644 index 00000000..6e268b6e --- /dev/null +++ b/tests/OpgTest/Core/Model/Entity/Document/ActionLogTest.php @@ -0,0 +1,21 @@ +actionLog = new ActionLog(); + } + + public function testSetUp() + { + $this->assertTrue($this->actionLog instanceof ActionLog); + } +} diff --git a/tests/OpgTest/Core/Model/Entity/Document/Decorators/SystemTypeTest.php b/tests/OpgTest/Core/Model/Entity/Document/Decorators/SystemTypeTest.php new file mode 100644 index 00000000..24d15868 --- /dev/null +++ b/tests/OpgTest/Core/Model/Entity/Document/Decorators/SystemTypeTest.php @@ -0,0 +1,39 @@ +SystemType = new SystemTypeStub(); + } + + public function testSetUp() + { + $this->assertTrue($this->SystemType instanceof HasSystemType); + } + + public function testSetGetSystemType() + { + // Check that new object has blank type + $this->assertNull($this->SystemType->getSystemType()); + + // Add a system type + $expectedType = 'Random'; + $this->SystemType->setSystemType($expectedType); + + // Check the get() returns the value passed to set. + $this->assertEquals($expectedType, $this->SystemType->getSystemType()); + } +}