-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding iSite Contact Details support to Programme Options (#210)
- Loading branch information
1 parent
496e786
commit 13c4a18
Showing
5 changed files
with
166 additions
and
7 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,21 @@ | ||
<?php | ||
|
||
namespace BBC\ProgrammesPagesService\Domain\Enumeration; | ||
|
||
class ContactMediumEnum | ||
{ | ||
public const EMAIL = 'email'; | ||
public const SMS = 'sms'; | ||
public const PHONE = 'phone'; | ||
public const FAX = 'fax'; | ||
public const ADDRESS = 'address'; | ||
public const FACEBOOK = 'facebook'; | ||
public const TWITTER = 'twitter'; | ||
public const GOOGLE_PLUS = 'google-plus'; | ||
public const SPOTIFY = 'spotify'; | ||
public const PINTEREST = 'pinterest'; | ||
public const TUMBLR = 'tumblr'; | ||
public const STUMBLEUPON = 'stumbleupon'; | ||
public const INSTAGRAM = 'instagram'; | ||
public const OTHER = 'other'; | ||
} |
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,43 @@ | ||
<?php | ||
|
||
namespace BBC\ProgrammesPagesService\Domain\ValueObject; | ||
|
||
use BBC\ProgrammesPagesService\Domain\Enumeration\ContactMediumEnum; | ||
|
||
class ContactDetails | ||
{ | ||
/** | ||
* @see ContactMediumEnum::VALID_MEDIUM | ||
* | ||
* @var string | ||
*/ | ||
private $type; | ||
|
||
/** @var string */ | ||
private $value; | ||
|
||
/** @var string */ | ||
private $freetext; | ||
|
||
public function __construct(string $mediaType, string $value, string $freetext) | ||
{ | ||
$this->type = $mediaType; | ||
$this->value = $value; | ||
$this->freetext = $freetext; | ||
} | ||
|
||
public function getType(): string | ||
{ | ||
return $this->type; | ||
} | ||
|
||
public function getValue(): string | ||
{ | ||
return $this->value; | ||
} | ||
|
||
public function getFreetext(): string | ||
{ | ||
return $this->freetext; | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -3,7 +3,8 @@ | |
namespace Tests\BBC\ProgrammesPagesService\Mapper\ProgrammesDbToDomain; | ||
|
||
use BBC\ProgrammesPagesService\Domain\Entity\Options; | ||
use BBC\ProgrammesPagesService\Mapper\ProgrammesDbToDomain\OptionsMapper; | ||
use BBC\ProgrammesPagesService\Domain\ValueObject\ContactDetails; | ||
use BBC\ProgrammesPagesService\Mapper\ProgrammesDbToDomain\MapperFactory; | ||
|
||
class OptionsMapperTest extends BaseMapperTestCase | ||
{ | ||
|
@@ -48,11 +49,12 @@ public function testBasicOptionsNoHierarchy() | |
'livepromo_block' => null, | ||
'prioritytext_block' => null, | ||
'navigation_links' => [], | ||
'contact_details' => [], | ||
]; | ||
|
||
$this->assertEquals( | ||
new Options($expectedOptions), | ||
$this->getMapper()->getDomainModel($options) | ||
(new MapperFactory())->getOptionsMapper()->getDomainModel($options) | ||
); | ||
} | ||
|
||
|
@@ -109,16 +111,76 @@ public function testInheritanceOfOptions() | |
'livepromo_block' => null, | ||
'prioritytext_block' => null, | ||
'navigation_links' => [], | ||
'contact_details' => [], | ||
]; | ||
|
||
$this->assertEquals( | ||
new Options($expectedOptions), | ||
$this->getMapper()->getDomainModel($childOptions, $parentOptions, $grandparentOptions) | ||
(new MapperFactory())->getOptionsMapper()->getDomainModel($childOptions, $parentOptions, $grandparentOptions) | ||
); | ||
} | ||
|
||
private function getMapper(): OptionsMapper | ||
public function testCanAddMappedContact() | ||
{ | ||
return new OptionsMapper($this->getMapperFactory()); | ||
$options = [ | ||
'language' => 'cy', | ||
'second_option' => null, | ||
'contact_details' => [ | ||
[ | ||
'type' => 'email', | ||
'value' => '[email protected]', | ||
'freetext' => 'Free text', | ||
], | ||
[ | ||
'type' => 'email', | ||
'value' => '[email protected]', | ||
'freetext' => 'Free text', | ||
], | ||
], | ||
]; | ||
|
||
$expectedOptions = [ | ||
'projectId' => null, | ||
'language' => 'cy', | ||
'branding_id' => 'br-00002', | ||
'second_option' => null, | ||
'pulse_survey' => null, | ||
'brand_2016_layout' => false, | ||
'brand_2016_layout_use_minimap' => false, | ||
'show_clip_cards' => true, | ||
'show_gallery_cards' => true, | ||
'double_width_first_promo' => false, | ||
'show_tracklist_inadvance' => false, | ||
'show_tracklist_timings' => false, | ||
'show_enhanced_navigation' => false, | ||
'comments_clips_id' => null, | ||
'comments_clips_enabled' => false, | ||
'comments_episodes_id' => null, | ||
'comments_episodes_enabled' => false, | ||
'playlister_popularity_enabled' => false, | ||
'recipes_enabled' => false, | ||
'brand_layout' => 'availability', | ||
'promoted_programmes' => [], | ||
'live_stream_id' => null, | ||
'live_stream_heading' => null, | ||
'pid_override_url' => null, | ||
'pid_override_code' => null, | ||
'ivote_block' => null, | ||
'comingsoon_block' => null, | ||
'comingsoon_textonly' => null, | ||
'bbc_site' => null, | ||
'livepromo_block' => null, | ||
'prioritytext_block' => null, | ||
'navigation_links' => [], | ||
'contact_details' => [ | ||
new ContactDetails('email', '[email protected]', 'Free text'), | ||
new ContactDetails('email', '[email protected]', 'Free text'), | ||
], | ||
]; | ||
|
||
$this->assertEquals( | ||
new Options($expectedOptions), | ||
(new MapperFactory())->getOptionsMapper()->getDomainModel($options) | ||
); | ||
} | ||
} |