| @@ 10-43 (lines=34) @@ | ||
| 7 | use Yproximite\Api\Model\Article\ArticleTranslation; |
|
| 8 | use Yproximite\Api\Message\Article\ArticleTranslationMessage; |
|
| 9 | ||
| 10 | class ArticleTranslationMessageSpec extends ObjectBehavior |
|
| 11 | { |
|
| 12 | function it_is_initializable() |
|
| 13 | { |
|
| 14 | $this->shouldHaveType(ArticleTranslationMessage::class); |
|
| 15 | } |
|
| 16 | ||
| 17 | function it_should_build() |
|
| 18 | { |
|
| 19 | $this->setTitle('Big title'); |
|
| 20 | $this->setBody('Long body'); |
|
| 21 | ||
| 22 | $data = [ |
|
| 23 | 'title' => 'Big title', |
|
| 24 | 'body' => 'Long body', |
|
| 25 | ]; |
|
| 26 | ||
| 27 | $this->build()->shouldReturn($data); |
|
| 28 | } |
|
| 29 | ||
| 30 | function it_should_create_from_article_translation(ArticleTranslation $translation) |
|
| 31 | { |
|
| 32 | $translation->getLocale()->willReturn('en'); |
|
| 33 | $translation->getTitle()->willReturn('Big title'); |
|
| 34 | $translation->getBody()->willReturn('Long body'); |
|
| 35 | ||
| 36 | $message = new ArticleTranslationMessage(); |
|
| 37 | $message->setLocale('en'); |
|
| 38 | $message->setTitle('Big title'); |
|
| 39 | $message->setBody('Long body'); |
|
| 40 | ||
| 41 | $this::createFromArticleTranslation($translation)->shouldBeLike($message); |
|
| 42 | } |
|
| 43 | } |
|
| 44 | ||
| @@ 10-43 (lines=34) @@ | ||
| 7 | use Yproximite\Api\Model\Article\CategoryTranslation; |
|
| 8 | use Yproximite\Api\Message\Article\CategoryTranslationMessage; |
|
| 9 | ||
| 10 | class CategoryTranslationMessageSpec extends ObjectBehavior |
|
| 11 | { |
|
| 12 | function it_is_initializable() |
|
| 13 | { |
|
| 14 | $this->shouldHaveType(CategoryTranslationMessage::class); |
|
| 15 | } |
|
| 16 | ||
| 17 | function it_should_build() |
|
| 18 | { |
|
| 19 | $this->setTitle('Category alpha'); |
|
| 20 | $this->setDescription('Some information'); |
|
| 21 | ||
| 22 | $data = [ |
|
| 23 | 'title' => 'Category alpha', |
|
| 24 | 'description' => 'Some information', |
|
| 25 | ]; |
|
| 26 | ||
| 27 | $this->build()->shouldReturn($data); |
|
| 28 | } |
|
| 29 | ||
| 30 | function it_should_create_from_category_translation(CategoryTranslation $translation) |
|
| 31 | { |
|
| 32 | $translation->getLocale()->willReturn('en'); |
|
| 33 | $translation->getTitle()->willReturn('Big title'); |
|
| 34 | $translation->getDescription()->willReturn('Long description'); |
|
| 35 | ||
| 36 | $message = new CategoryTranslationMessage(); |
|
| 37 | $message->setLocale('en'); |
|
| 38 | $message->setTitle('Big title'); |
|
| 39 | $message->setDescription('Long description'); |
|
| 40 | ||
| 41 | $this::createFromCategoryTranslation($translation)->shouldBeLike($message); |
|
| 42 | } |
|
| 43 | } |
|
| 44 | ||
| @@ 10-43 (lines=34) @@ | ||
| 7 | use Yproximite\Api\Model\Company\Company; |
|
| 8 | use Yproximite\Api\Message\Company\CompanyPatchMessage; |
|
| 9 | ||
| 10 | class CompanyPatchMessageSpec extends ObjectBehavior |
|
| 11 | { |
|
| 12 | function it_is_initializable() |
|
| 13 | { |
|
| 14 | $this->shouldHaveType(CompanyPatchMessage::class); |
|
| 15 | } |
|
| 16 | ||
| 17 | function it_should_build() |
|
| 18 | { |
|
| 19 | $this->setParentId(5); |
|
| 20 | $this->setName('First company'); |
|
| 21 | ||
| 22 | $data = [ |
|
| 23 | 'companyName' => 'First company', |
|
| 24 | 'parent' => 5, |
|
| 25 | ]; |
|
| 26 | ||
| 27 | $this->build()->shouldReturn($data); |
|
| 28 | } |
|
| 29 | ||
| 30 | function it_should_create_from_company(Company $company) |
|
| 31 | { |
|
| 32 | $company->getId()->willReturn(1); |
|
| 33 | $company->getName()->willReturn('First company'); |
|
| 34 | $company->getParentId()->willReturn(5); |
|
| 35 | ||
| 36 | $message = new CompanyPatchMessage(); |
|
| 37 | $message->setId(1); |
|
| 38 | $message->setName('First company'); |
|
| 39 | $message->setParentId(5); |
|
| 40 | ||
| 41 | $this::createFromCompany($company)->shouldBeLike($message); |
|
| 42 | } |
|
| 43 | } |
|
| 44 | ||
| @@ 10-43 (lines=34) @@ | ||
| 7 | use Yproximite\Api\Model\Location\LocationTranslation; |
|
| 8 | use Yproximite\Api\Message\Location\LocationTranslationMessage; |
|
| 9 | ||
| 10 | class LocationTranslationMessageSpec extends ObjectBehavior |
|
| 11 | { |
|
| 12 | function it_is_initializable() |
|
| 13 | { |
|
| 14 | $this->shouldHaveType(LocationTranslationMessage::class); |
|
| 15 | } |
|
| 16 | ||
| 17 | function it_should_build() |
|
| 18 | { |
|
| 19 | $this->setTitle('Some location'); |
|
| 20 | $this->setOpeningHours('24/7'); |
|
| 21 | ||
| 22 | $data = [ |
|
| 23 | 'title' => 'Some location', |
|
| 24 | 'openingHours' => '24/7', |
|
| 25 | ]; |
|
| 26 | ||
| 27 | $this->build()->shouldReturn($data); |
|
| 28 | } |
|
| 29 | ||
| 30 | function it_should_create_from_article_translation(LocationTranslation $translation) |
|
| 31 | { |
|
| 32 | $translation->getLocale()->willReturn('en'); |
|
| 33 | $translation->getTitle()->willReturn('Big title'); |
|
| 34 | $translation->getOpeningHours()->willReturn('24/7'); |
|
| 35 | ||
| 36 | $message = new LocationTranslationMessage(); |
|
| 37 | $message->setLocale('en'); |
|
| 38 | $message->setTitle('Big title'); |
|
| 39 | $message->setOpeningHours('24/7'); |
|
| 40 | ||
| 41 | $this::createFromLocationTranslation($translation)->shouldBeLike($message); |
|
| 42 | } |
|
| 43 | } |
|
| 44 | ||
| @@ 10-43 (lines=34) @@ | ||
| 7 | use Yproximite\Api\Model\TeamWorker\TeamWorker; |
|
| 8 | use Yproximite\Api\Message\TeamWorker\TeamWorkerPatchMessage; |
|
| 9 | ||
| 10 | class TeamWorkerPatchMessageSpec extends ObjectBehavior |
|
| 11 | { |
|
| 12 | function it_is_initializable() |
|
| 13 | { |
|
| 14 | $this->shouldHaveType(TeamWorkerPatchMessage::class); |
|
| 15 | } |
|
| 16 | ||
| 17 | function it_should_build() |
|
| 18 | { |
|
| 19 | $this->setLastName('Bob'); |
|
| 20 | $this->setFirstName('Morane'); |
|
| 21 | ||
| 22 | $data = [ |
|
| 23 | 'lastName' => 'Bob', |
|
| 24 | 'firstName' => 'Morane', |
|
| 25 | ]; |
|
| 26 | ||
| 27 | $this->build()->shouldReturn($data); |
|
| 28 | } |
|
| 29 | ||
| 30 | function it_should_create_from_team_worker(TeamWorker $teamWorker) |
|
| 31 | { |
|
| 32 | $teamWorker->getId()->willReturn(1); |
|
| 33 | $teamWorker->getLastName()->willReturn('Bob'); |
|
| 34 | $teamWorker->getFirstName()->willReturn('Morane'); |
|
| 35 | ||
| 36 | $message = new TeamWorkerPatchMessage(); |
|
| 37 | $message->setId(1); |
|
| 38 | $message->setLastName('Bob'); |
|
| 39 | $message->setFirstName('Morane'); |
|
| 40 | ||
| 41 | $this::createFromTeamWorker($teamWorker)->shouldBeLike($message); |
|
| 42 | } |
|
| 43 | } |
|
| 44 | ||