This repository has been archived by the owner on Apr 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #163 from ministryofjustice/SDV-32_Action_Log
[#SDV-32] Introduced a new object for the Action Log.
- Loading branch information
Showing
7 changed files
with
152 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Opg\Core\Model\Entity\Document; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use JMS\Serializer\Annotation\Exclude; | ||
use JMS\Serializer\Annotation\Type; | ||
use JMS\Serializer\Annotation\Accessor; | ||
use JMS\Serializer\Annotation\ReadOnly; | ||
use Opg\Core\Model\Entity\Document\Decorators\AssetLog; | ||
use Opg\Core\Model\Entity\Document\Decorators\HasAssetLog; | ||
use Opg\Core\Model\Entity\Document\Decorators\SystemType; | ||
use Opg\Core\Model\Entity\Document\Decorators\HasSystemType; | ||
|
||
/** | ||
* @ORM\Entity | ||
* ORM\entity(repositoryClass="Application\Model\Repository\DocumentRepository") | ||
* | ||
* Class Correspondence | ||
* @package Opg\Core\Model\Entity\Document | ||
*/ | ||
class ActionLog extends Document implements HasAssetLog, HasSystemType | ||
{ | ||
use AssetLog; | ||
use SystemType; | ||
|
||
/** | ||
* @Type("string") | ||
* @Accessor(getter="getDirection") | ||
* @ReadOnly | ||
*/ | ||
protected $direction = self::DOCUMENT_INTERNAL_CORRESPONDENCE; | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Opg/Core/Model/Entity/Document/Decorators/HasSystemType.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Opg\Core\Model\Entity\Document\Decorators; | ||
|
||
interface HasSystemType | ||
{ | ||
/** | ||
* @param string $systemType | ||
* @return HasSystemType | ||
*/ | ||
public function setSystemType($systemType); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getSystemType(); | ||
} |
37 changes: 37 additions & 0 deletions
37
src/Opg/Core/Model/Entity/Document/Decorators/SystemType.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Opg\Core\Model\Entity\Document\Decorators; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
/** | ||
* Class AssetLog | ||
* @package Opg\Core\Model\Entity\Document\Decorators | ||
*/ | ||
trait SystemType | ||
{ | ||
/** | ||
* @ORM\Column(type = "string", nullable = true) | ||
* @var string | ||
*/ | ||
protected $systemType; | ||
|
||
/** | ||
* @param string $systemType | ||
* @return HasSystemType | ||
*/ | ||
public function setSystemType($systemType) | ||
{ | ||
$this->systemType = $systemType; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getSystemType() | ||
{ | ||
return $this->systemType; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
tests/OpgTest/Core/Model/Entity/Document/ActionLogTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace OpgTest\Core\Model\Entity\Document; | ||
|
||
use Opg\Core\Model\Entity\Document\ActionLog; | ||
|
||
class ActionLogTest extends \PHPUnit_Framework_TestCase { | ||
|
||
/** @var ActionLog */ | ||
protected $actionLog; | ||
|
||
public function setUp() | ||
{ | ||
$this->actionLog = new ActionLog(); | ||
} | ||
|
||
public function testSetUp() | ||
{ | ||
$this->assertTrue($this->actionLog instanceof ActionLog); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
tests/OpgTest/Core/Model/Entity/Document/Decorators/SystemTypeTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace OpgTest\Core\Model\Entity\Document\Decorators; | ||
|
||
use Opg\Core\Model\Entity\Document\Decorators\SystemType; | ||
use Opg\Core\Model\Entity\Document\Decorators\HasSystemType; | ||
|
||
class SystemTypeStub implements HasSystemType | ||
{ | ||
use SystemType; | ||
} | ||
class SystemTypeTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** @var SystemTypeStub */ | ||
protected $SystemType; | ||
|
||
public function setUp() | ||
{ | ||
$this->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()); | ||
} | ||
} |