Skip to content

Commit

Permalink
Issue #23: Renamed targed.
Browse files Browse the repository at this point in the history
  • Loading branch information
imanoleguskiza committed Oct 5, 2017
1 parent a57b709 commit 30b234c
Show file tree
Hide file tree
Showing 36 changed files with 240 additions and 207 deletions.
10 changes: 5 additions & 5 deletions spec/Messages/Requests/CreateRequestSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use EC\Poetry\Messages\Components\ReferenceDocument;
use EC\Poetry\Messages\Components\ReturnAddress;
use EC\Poetry\Messages\Components\Source;
use EC\Poetry\Messages\Components\Target;
use EC\Poetry\Messages\Components\Attribution;
use EC\Poetry\Messages\Requests\CreateRequest;
use EC\Poetry\Services\Settings;
use PhpSpec\ObjectBehavior;
Expand All @@ -17,7 +17,7 @@
use spec\EC\Poetry\Messages\Traits\AssertReferenceDocumentsTrait;
use spec\EC\Poetry\Messages\Traits\AssertReturnAddressTrait;
use spec\EC\Poetry\Messages\Traits\AssertSourceTrait;
use spec\EC\Poetry\Messages\Traits\AssertTargetsTrait;
use spec\EC\Poetry\Messages\Traits\AssertAttributionsTrait;

class CreateRequestSpec extends ObjectBehavior
{
Expand All @@ -26,7 +26,7 @@ class CreateRequestSpec extends ObjectBehavior
use AssertReturnAddressTrait;
use AssertContactsTrait;
use AssertReferenceDocumentsTrait;
use AssertTargetsTrait;
use AssertAttributionsTrait;

function let(Identifier $identifier, Settings $settings)
{
Expand Down Expand Up @@ -63,8 +63,8 @@ function it_has_reference_documents(ReferenceDocument $document1, ReferenceDocum
$this->assertReferenceDocuments($document1, $document2, $document3, $document4);
}

function it_has_targets(Target $target1, Target $target2, Target $target3, Target $target4)
function it_has_attributions(Attribution $attribution1, Attribution $attribution2, Attribution $attribution3, Attribution $attribution4)
{
$this->assertTargets($target1, $target2, $target3, $target4);
$this->assertAttributions($attribution1, $attribution2, $attribution3, $attribution4);
}
}
46 changes: 46 additions & 0 deletions spec/Messages/Traits/AssertAttributionsTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace spec\EC\Poetry\Messages\Traits;

use EC\Poetry\Messages\Components\Attribution;

/**
* Trait AssertAttributionsTrait
*
* @method addAttribution(Attribution $attribution)
* @method setAttribution(array $documents)
* @method getAttributions()
* @method withAttribution()
*
* @package spec\EC\Poetry\Messages\Traits
*/
trait AssertAttributionsTrait
{
/**
* Assert Component.
*
* @param \EC\Poetry\Messages\Components\Attribution $attribution1
* @param \EC\Poetry\Messages\Components\Attribution $attribution2
* @param \EC\Poetry\Messages\Components\Attribution $attribution3
* @param \EC\Poetry\Messages\Components\Attribution $attribution4
*/
function assertAttributions($attribution1, $attribution2, $attribution3, $attribution4)
{
$this->addAttribution($attribution1)->shouldReturn($this);
$this->addAttribution($attribution2)->shouldReturn($this);
$this->getAttributions()->shouldBeArray();
$this->getAttributions()[0]->shouldBe($attribution1);
$this->getAttributions()[1]->shouldBe($attribution2);

$this->setAttribution([$attribution3, $attribution4])->shouldReturn($this);
$this->getAttributions()[0]->shouldNotBe($attribution1);
$this->getAttributions()[1]->shouldNotBe($attribution2);
$this->getAttributions()[0]->shouldBe($attribution3);
$this->getAttributions()[1]->shouldBe($attribution4);

$this->withAttribution()->shouldBeAnInstanceOf(Attribution::class);
$this->withAttribution()->shouldBeAnInstanceOf(Attribution::class);
$this->getAttributions()[2]->shouldBeAnInstanceOf(Attribution::class);
$this->getAttributions()[3]->shouldBeAnInstanceOf(Attribution::class);
}
}
2 changes: 1 addition & 1 deletion spec/Messages/Traits/AssertStatusesTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use EC\Poetry\Messages\Components as Component;

/**
* Trait AssertTargetsTrait
* Trait AssertAttributionsTrait
*
* @method addStatus(Component\Status $status)
* @method setStatuses(array $statuses)
Expand Down
46 changes: 0 additions & 46 deletions spec/Messages/Traits/AssertTargetsTrait.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
use Symfony\Component\Validator\Constraints as Assert;

/**
* Class Target
* Class Attribution
*
* @package EC\Poetry\Messages\Components
*/
class Target extends AbstractComponent
class Attribution extends AbstractComponent
{
use WithContactsTrait;

Expand All @@ -34,7 +34,7 @@ class Target extends AbstractComponent
*/
public function getTemplate()
{
return 'components::target';
return 'components::attribution';
}

/**
Expand Down Expand Up @@ -85,7 +85,8 @@ public function getFormat()

/**
* @param mixed $format
* @return Target
*
* @return Attribution
*/
public function setFormat($format)
{
Expand All @@ -105,7 +106,8 @@ public function getLanguage()

/**
* @param mixed $language
* @return Target
*
* @return Attribution
*/
public function setLanguage($language)
{
Expand All @@ -124,7 +126,8 @@ public function getTrackChanges()

/**
* @param mixed $trackChanges
* @return Target
*
* @return Attribution
*/
public function setTrackChanges($trackChanges)
{
Expand All @@ -143,7 +146,8 @@ public function getAction()

/**
* @param mixed $action
* @return Target
*
* @return Attribution
*/
public function setAction($action)
{
Expand All @@ -162,7 +166,8 @@ public function getRemark()

/**
* @param mixed $remark
* @return Target
*
* @return Attribution
*/
public function setRemark($remark)
{
Expand All @@ -181,7 +186,8 @@ public function getDelay()

/**
* @param mixed $delay
* @return Target
*
* @return Attribution
*/
public function setDelay($delay)
{
Expand All @@ -200,7 +206,8 @@ public function getDelayFormat()

/**
* @param mixed $delayFormat
* @return Target
*
* @return Attribution
*/
public function setDelayFormat($delayFormat)
{
Expand All @@ -219,7 +226,8 @@ public function getAcceptedDelay()

/**
* @param mixed $acceptedDelay
* @return Target
*
* @return Attribution
*/
public function setAcceptedDelay($acceptedDelay)
{
Expand All @@ -238,7 +246,8 @@ public function getAcceptedDelayFormat()

/**
* @param mixed $acceptedDelayFormat
* @return Target
*
* @return Attribution
*/
public function setAcceptedDelayFormat($acceptedDelayFormat)
{
Expand All @@ -255,9 +264,9 @@ public function getTranslatedFile()
return $this->translatedFile;
}

/**
/**
* @param mixed $translatedFile
* @return Target
* @return Attribution
*/
public function setTranslatedFile($translatedFile)
{
Expand All @@ -267,23 +276,23 @@ public function setTranslatedFile($translatedFile)
}

/**
* @return \EC\Poetry\Messages\Components\TargetReturnAddress[]
* @return \EC\Poetry\Messages\Components\AttributionReturnAddress[]
*/
public function getReturnAddresses()
{
return $this->returnAddresses;
}

/**
* @param \EC\Poetry\Messages\Components\TargetReturnAddress[] $returnAddresses
* @param \EC\Poetry\Messages\Components\AttributionReturnAddress[] $returnAddresses
*/
public function setReturnAddresses($returnAddresses)
{
$this->returnAddresses = $returnAddresses;
}

/**
* @param \EC\Poetry\Messages\Components\TargetReturnAddress $returnAddress
* @param \EC\Poetry\Messages\Components\AttributionReturnAddress $returnAddress
*/
public function addReturnAddress($returnAddress)
{
Expand All @@ -293,12 +302,12 @@ public function addReturnAddress($returnAddress)
/**
* Factory method: create a new contact and return its instance.
*
* @return \EC\Poetry\Messages\Components\TargetReturnAddress
* @return \EC\Poetry\Messages\Components\AttributionReturnAddress
* Contact instance.
*/
public function withReturnAddress()
{
$this->returnAddresses[] = new TargetReturnAddress();
$this->returnAddresses[] = new AttributionReturnAddress();

return end($this->returnAddresses);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
namespace EC\Poetry\Messages\Components;

/**
* Class TargetReturnAddress
* Class AttributionReturnAddress
*
* @package EC\Poetry\Messages\Components
*/
class TargetReturnAddress extends ReturnAddress
class AttributionReturnAddress extends ReturnAddress
{

/**
* {@inheritdoc}
*/
public function getTemplate()
{
return 'components::target-return-address';
return 'components::attribution-return-address';
}
}
2 changes: 1 addition & 1 deletion src/Messages/Components/Constraints/DetailsDestination.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
* @Annotation
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
* @Attribution({"PROPERTY", "METHOD", "ANNOTATION"})
*
* @package EC\Poetry\Messages\Components\Constraints
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Messages/Components/Constraints/DetailsProcedure.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
* @Annotation
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
* @Attribution({"PROPERTY", "METHOD", "ANNOTATION"})
*
* @package EC\Poetry\Messages\Components\Constraints
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Messages/Components/Constraints/DetailsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
* @Annotation
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
* @Attribution({"PROPERTY", "METHOD", "ANNOTATION"})
*
* @package EC\Poetry\Messages\Components\Constraints
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Messages/Components/Constraints/DocumentFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
* @Annotation
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
* @Attribution({"PROPERTY", "METHOD", "ANNOTATION"})
*
* @package EC\Poetry\Messages\Components\Constraints
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Messages/Components/Constraints/SourceChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
* @Annotation
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
* @Attribution({"PROPERTY", "METHOD", "ANNOTATION"})
*
* @package EC\Poetry\Messages\Components\Constraints
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
* @Annotation
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
* @Attribution({"PROPERTY", "METHOD", "ANNOTATION"})
*
* @package EC\Poetry\Messages\Components\Constraints
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Messages/Components/Constraints/StatusCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
* @Annotation
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
* @Attribution({"PROPERTY", "METHOD", "ANNOTATION"})
*
* @package EC\Poetry\Messages\Components\Constraints
*/
Expand Down
Loading

0 comments on commit 30b234c

Please sign in to comment.