Skip to content

Commit

Permalink
Add ContactTagFactory (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
lruozzi9 committed Apr 15, 2022
1 parent 0f038ac commit 290c762
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
33 changes: 33 additions & 0 deletions spec/Factory/ActiveCampaign/ContactTagFactorySpec.php
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

namespace spec\Webgriffe\SyliusActiveCampaignPlugin\Factory\ActiveCampaign;

use Webgriffe\SyliusActiveCampaignPlugin\Factory\ActiveCampaign\ContactTagFactory;
use PhpSpec\ObjectBehavior;
use Webgriffe\SyliusActiveCampaignPlugin\Factory\ActiveCampaign\ContactTagFactoryInterface;
use Webgriffe\SyliusActiveCampaignPlugin\Model\ActiveCampaign\ContactTag;

class ContactTagFactorySpec extends ObjectBehavior
{
public function let(): void
{
$this->beConstructedWith();
}

public function it_is_initializable(): void
{
$this->shouldBeAnInstanceOf(ContactTagFactory::class);
}

public function it_implements_contact_tag_factory_interface(): void
{
$this->shouldImplement(ContactTagFactoryInterface::class);
}

public function it_should_returns_a_contact_tag_instance(): void
{
$this->createNew(2, 3)->shouldReturnAnInstanceOf(ContactTag::class);
}
}
16 changes: 16 additions & 0 deletions src/Factory/ActiveCampaign/ContactTagFactory.php
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace Webgriffe\SyliusActiveCampaignPlugin\Factory\ActiveCampaign;

use Webgriffe\SyliusActiveCampaignPlugin\Model\ActiveCampaign\ContactTag;
use Webgriffe\SyliusActiveCampaignPlugin\Model\ActiveCampaign\ContactTagInterface;

final class ContactTagFactory implements ContactTagFactoryInterface
{
public function createNew(int $contactId, int $tagId): ContactTagInterface
{
return new ContactTag($contactId, $tagId);
}
}
12 changes: 12 additions & 0 deletions src/Factory/ActiveCampaign/ContactTagFactoryInterface.php
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace Webgriffe\SyliusActiveCampaignPlugin\Factory\ActiveCampaign;

use Webgriffe\SyliusActiveCampaignPlugin\Model\ActiveCampaign\ContactTagInterface;

interface ContactTagFactoryInterface
{
public function createNew(int $contactId, int $tagId): ContactTagInterface;
}
3 changes: 3 additions & 0 deletions src/Resources/config/services/factory.xml
Expand Up @@ -19,5 +19,8 @@

<service id="webgriffe.sylius_active_campaign_plugin.factory.active_campaign.tag"
class="Webgriffe\SyliusActiveCampaignPlugin\Factory\ActiveCampaign\TagFactory"/>

<service id="webgriffe.sylius_active_campaign_plugin.factory.active_campaign.contact_tag"
class="Webgriffe\SyliusActiveCampaignPlugin\Factory\ActiveCampaign\ContactTagFactory"/>
</services>
</container>

0 comments on commit 290c762

Please sign in to comment.