Add integration tests for 'fullPostFeaturedImagePosition'

[MAILPOET-2491]
This commit is contained in:
Jan Jakeš
2020-02-13 14:54:16 +01:00
committed by Jack Kitterhing
parent 8b4537676a
commit b52def5c57

View File

@@ -233,6 +233,50 @@ class PostContentTransformerTest extends \MailPoetTest {
expect($result[0]['blocks'][0]['blocks'])->equals([$this->titleMock, $this->contentMock[0]]); expect($result[0]['blocks'][0]['blocks'])->equals([$this->titleMock, $this->contentMock[0]]);
} }
public function testShouldAddImageForFullPost() {
$args = [
'withLayout' => true,
'displayType' => 'full',
'fullPostFeaturedImagePosition' => 'centered',
];
$transformer = $this->getTransformer($args, $this->contentMock, $this->titleMock, $this->imageMock);
$result = $transformer->transform([]);
expect($result[0]['blocks'][0]['blocks'][0])->equals($this->titleMock);
expect($result[0]['blocks'][0]['blocks'][1])->equals($this->imageMock);
expect($result[0]['blocks'][0]['blocks'][2])->equals($this->contentMock[0]);
expect($result[0]['blocks'][0]['blocks'])->count(3);
}
public function testShouldNotAddImageForExistingFullPost() {
$args = [
'withLayout' => true,
'displayType' => 'full',
'featuredImagePosition' => 'centered',
];
$transformer = $this->getTransformer($args, $this->contentMock, $this->titleMock, $this->imageMock);
$result = $transformer->transform([]);
expect($result[0]['blocks'][0]['blocks'][0])->equals($this->titleMock);
expect($result[0]['blocks'][0]['blocks'][1])->equals($this->contentMock[0]);
expect($result[0]['blocks'][0]['blocks'])->count(2);
}
public function testShouldAddImageForExistingFullPostProduct() {
$args = [
'withLayout' => true,
'displayType' => 'full',
'featuredImagePosition' => 'centered',
];
$transformer = $this->getTransformer($args, $this->contentMock, $this->titleMock, $this->imageMock, true);
$result = $transformer->transform([]);
expect($result[0]['blocks'][0]['blocks'][0])->equals($this->titleMock);
expect($result[0]['blocks'][0]['blocks'][1])->equals($this->imageMock);
expect($result[0]['blocks'][0]['blocks'][2])->equals($this->contentMock[0]);
expect($result[0]['blocks'][0]['blocks'])->count(3);
}
public function testShouldAddClassToParagraphsInFullPostsWithLayout() { public function testShouldAddClassToParagraphsInFullPostsWithLayout() {
$args = [ $args = [
'withLayout' => true, 'withLayout' => true,
@@ -302,14 +346,14 @@ class PostContentTransformerTest extends \MailPoetTest {
/** /**
* @return PostTransformer * @return PostTransformer
*/ */
private function getTransformer(array $args, array $content, array $title, array $image = null) { private function getTransformer(array $args, array $content, array $title, array $image = null, bool $isProduct = false) {
$extractor = $this->make( $extractor = $this->make(
PostTransformerContentsExtractor::class, PostTransformerContentsExtractor::class,
[ [
'getContent' => $content, 'getContent' => $content,
'getFeaturedImage' => $image, 'getFeaturedImage' => $image,
'getTitle' => $title, 'getTitle' => $title,
'isProduct' => false, 'isProduct' => $isProduct,
] ]
); );
$transformer = new PostTransformer($args, $extractor); $transformer = new PostTransformer($args, $extractor);