Skip to content
This repository has been archived by the owner on Apr 11, 2018. It is now read-only.

Commit

Permalink
Merge b73dc08 into bc15d59
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulVM committed Dec 19, 2014
2 parents bc15d59 + b73dc08 commit 765dd43
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 28 deletions.
33 changes: 33 additions & 0 deletions src/Opg/Core/Model/Entity/Document/ActionLog.php
@@ -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 src/Opg/Core/Model/Entity/Document/Decorators/HasSystemType.php
@@ -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 src/Opg/Core/Model/Entity/Document/Decorators/SystemType.php
@@ -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;
}
}
1 change: 1 addition & 0 deletions src/Opg/Core/Model/Entity/Document/Document.php
Expand Up @@ -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",
* })
*
Expand Down
32 changes: 4 additions & 28 deletions src/Opg/Core/Model/Entity/Document/OutgoingDocument.php
Expand Up @@ -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
Expand All @@ -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")
Expand All @@ -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;
}

}
21 changes: 21 additions & 0 deletions tests/OpgTest/Core/Model/Entity/Document/ActionLogTest.php
@@ -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);
}
}
@@ -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());
}
}

0 comments on commit 765dd43

Please sign in to comment.