From 2b0d1ea5c1ca7f4656e00d3da8d0cc38d01899d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lys=C3=BD?= Date: Tue, 24 Oct 2023 17:30:07 +0200 Subject: [PATCH] Update unit test after updating codeception/verify [MAILPOET-5591] --- .../Engine/Renderer/PreprocessManagerTest.php | 2 +- .../BlocksWidthPreprocessorTest.php | 42 +++++++++---------- .../Preprocessors/CleanupPreprocessorTest.php | 14 +++---- .../TypographyPreprocessorTest.php | 40 +++++++++--------- 4 files changed, 49 insertions(+), 49 deletions(-) diff --git a/mailpoet/tests/unit/EmailEditor/Engine/Renderer/PreprocessManagerTest.php b/mailpoet/tests/unit/EmailEditor/Engine/Renderer/PreprocessManagerTest.php index 1f9d95d67d..6c9d26351f 100644 --- a/mailpoet/tests/unit/EmailEditor/Engine/Renderer/PreprocessManagerTest.php +++ b/mailpoet/tests/unit/EmailEditor/Engine/Renderer/PreprocessManagerTest.php @@ -37,6 +37,6 @@ class PreprocessManagerTest extends \MailPoetUnitTest { $preprocessManager = new PreprocessManager($cleanup, $topLevel, $blocksWidth, $typography); $preprocessManager->registerPreprocessor($secondPreprocessor); - expect($preprocessManager->preprocess([], $layoutStyles))->equals([]); + verify($preprocessManager->preprocess([], $layoutStyles))->equals([]); } } diff --git a/mailpoet/tests/unit/EmailEditor/Engine/Renderer/Preprocessors/BlocksWidthPreprocessorTest.php b/mailpoet/tests/unit/EmailEditor/Engine/Renderer/Preprocessors/BlocksWidthPreprocessorTest.php index 15131d8ac9..0323f5f136 100644 --- a/mailpoet/tests/unit/EmailEditor/Engine/Renderer/Preprocessors/BlocksWidthPreprocessorTest.php +++ b/mailpoet/tests/unit/EmailEditor/Engine/Renderer/Preprocessors/BlocksWidthPreprocessorTest.php @@ -44,11 +44,11 @@ class BlocksWidthPreprocessorTest extends \MailPoetUnitTest { ]]; $result = $this->preprocessor->preprocess($blocks, ['width' => '660px', 'padding' => ['left' => '0px', 'right' => '0px']]); $result = $result[0]; - expect($result['email_attrs']['width'])->equals('660px'); - expect($result['innerBlocks'])->count(3); - expect($result['innerBlocks'][0]['email_attrs']['width'])->equals('330px'); // 660 * 0.5 - expect($result['innerBlocks'][1]['email_attrs']['width'])->equals('165px'); // 660 * 0.25 - expect($result['innerBlocks'][2]['email_attrs']['width'])->equals('100px'); + verify($result['email_attrs']['width'])->equals('660px'); + verify($result['innerBlocks'])->arrayCount(3); + verify($result['innerBlocks'][0]['email_attrs']['width'])->equals('330px'); // 660 * 0.5 + verify($result['innerBlocks'][1]['email_attrs']['width'])->equals('165px'); // 660 * 0.25 + verify($result['innerBlocks'][2]['email_attrs']['width'])->equals('100px'); } public function testItCalculatesWidthWithLayoutPadding(): void { @@ -81,10 +81,10 @@ class BlocksWidthPreprocessorTest extends \MailPoetUnitTest { ]]; $result = $this->preprocessor->preprocess($blocks, ['width' => '600px', 'padding' => ['left' => '20px', 'right' => '20px']]); $result = $result[0]; - expect($result['innerBlocks'])->count(3); - expect($result['innerBlocks'][0]['email_attrs']['width'])->equals('185px'); // (600 - 20 - 20) * 0.33 - expect($result['innerBlocks'][1]['email_attrs']['width'])->equals('100px'); - expect($result['innerBlocks'][2]['email_attrs']['width'])->equals('112px'); // (600 - 20 - 20) * 0.2 + verify($result['innerBlocks'])->arrayCount(3); + verify($result['innerBlocks'][0]['email_attrs']['width'])->equals('185px'); // (600 - 20 - 20) * 0.33 + verify($result['innerBlocks'][1]['email_attrs']['width'])->equals('100px'); + verify($result['innerBlocks'][2]['email_attrs']['width'])->equals('112px'); // (600 - 20 - 20) * 0.2 } public function testItCalculatesWidthOfBlockInColumn(): void { @@ -139,11 +139,11 @@ class BlocksWidthPreprocessorTest extends \MailPoetUnitTest { $result = $this->preprocessor->preprocess($blocks, ['width' => '660px', 'padding' => ['left' => '15px', 'right' => '15px']]); $innerBlocks = $result[0]['innerBlocks']; - expect($innerBlocks)->count(2); - expect($innerBlocks[0]['email_attrs']['width'])->equals('252px'); // (660 - 15 - 15) * 0.4 - expect($innerBlocks[0]['innerBlocks'][0])->hasNotKey('email_attrs'); // paragraph block should not have width - expect($innerBlocks[1]['email_attrs']['width'])->equals('378px'); // (660 - 15 - 15) * 0.6 - expect($innerBlocks[1]['innerBlocks'][0])->hasNotKey('email_attrs'); // paragraph block should not have width + verify($innerBlocks)->arrayCount(2); + verify($innerBlocks[0]['email_attrs']['width'])->equals('252px'); // (660 - 15 - 15) * 0.4 + verify($innerBlocks[0]['innerBlocks'][0])->arrayHasNotKey('email_attrs'); // paragraph block should not have width + verify($innerBlocks[1]['email_attrs']['width'])->equals('378px'); // (660 - 15 - 15) * 0.6 + verify($innerBlocks[1]['innerBlocks'][0])->arrayHasNotKey('email_attrs'); // paragraph block should not have width } public function testItAddsMissingColumnWidth(): void { @@ -189,12 +189,12 @@ class BlocksWidthPreprocessorTest extends \MailPoetUnitTest { $result = $this->preprocessor->preprocess($blocks, ['width' => '660px', 'padding' => ['left' => '30px', 'right' => '30px']]); $innerBlocks = $result[0]['innerBlocks']; - expect($innerBlocks)->count(3); - expect($innerBlocks[0]['email_attrs']['width'])->equals('200px'); // (660 - 30 - 30) * 0.33 - expect($innerBlocks[0]['innerBlocks'][0])->hasNotKey('email_attrs'); // paragraph block should not have width - expect($innerBlocks[1]['email_attrs']['width'])->equals('200px'); // (660 - 30 - 30) * 0.33 - expect($innerBlocks[1]['innerBlocks'][0])->hasNotKey('email_attrs'); // paragraph block should not have width - expect($innerBlocks[2]['email_attrs']['width'])->equals('200px'); // (660 - 30 - 30) * 0.33 - expect($innerBlocks[2]['innerBlocks'][0])->hasNotKey('email_attrs'); // paragraph block should not have width + verify($innerBlocks)->arrayCount(3); + verify($innerBlocks[0]['email_attrs']['width'])->equals('200px'); // (660 - 30 - 30) * 0.33 + verify($innerBlocks[0]['innerBlocks'][0])->arrayHasNotKey('email_attrs'); // paragraph block should not have width + verify($innerBlocks[1]['email_attrs']['width'])->equals('200px'); // (660 - 30 - 30) * 0.33 + verify($innerBlocks[1]['innerBlocks'][0])->arrayHasNotKey('email_attrs'); // paragraph block should not have width + verify($innerBlocks[2]['email_attrs']['width'])->equals('200px'); // (660 - 30 - 30) * 0.33 + verify($innerBlocks[2]['innerBlocks'][0])->arrayHasNotKey('email_attrs'); // paragraph block should not have width } } diff --git a/mailpoet/tests/unit/EmailEditor/Engine/Renderer/Preprocessors/CleanupPreprocessorTest.php b/mailpoet/tests/unit/EmailEditor/Engine/Renderer/Preprocessors/CleanupPreprocessorTest.php index a253cdb4cb..b537800c30 100644 --- a/mailpoet/tests/unit/EmailEditor/Engine/Renderer/Preprocessors/CleanupPreprocessorTest.php +++ b/mailpoet/tests/unit/EmailEditor/Engine/Renderer/Preprocessors/CleanupPreprocessorTest.php @@ -37,9 +37,9 @@ class CleanupPreprocessorTest extends \MailPoetUnitTest { self::PARAGRAPH_BLOCK, ]; $result = $this->preprocessor->preprocess($blocks, []); - expect($result)->count(2); - expect($result[0])->equals(self::COLUMNS_BLOCK); - expect($result[1])->equals(self::PARAGRAPH_BLOCK); + verify($result)->arrayCount(2); + verify($result[0])->equals(self::COLUMNS_BLOCK); + verify($result[1])->equals(self::PARAGRAPH_BLOCK); } public function testItPreservesAllRelevantBlocks(): void { @@ -49,9 +49,9 @@ class CleanupPreprocessorTest extends \MailPoetUnitTest { self::COLUMNS_BLOCK, ]; $result = $this->preprocessor->preprocess($blocks, []); - expect($result)->count(3); - expect($result[0])->equals(self::COLUMNS_BLOCK); - expect($result[1])->equals(self::PARAGRAPH_BLOCK); - expect($result[2])->equals(self::COLUMNS_BLOCK); + verify($result)->arrayCount(3); + verify($result[0])->equals(self::COLUMNS_BLOCK); + verify($result[1])->equals(self::PARAGRAPH_BLOCK); + verify($result[2])->equals(self::COLUMNS_BLOCK); } } diff --git a/mailpoet/tests/unit/EmailEditor/Engine/Renderer/Preprocessors/TypographyPreprocessorTest.php b/mailpoet/tests/unit/EmailEditor/Engine/Renderer/Preprocessors/TypographyPreprocessorTest.php index a2c63640bd..b4ab03ed54 100644 --- a/mailpoet/tests/unit/EmailEditor/Engine/Renderer/Preprocessors/TypographyPreprocessorTest.php +++ b/mailpoet/tests/unit/EmailEditor/Engine/Renderer/Preprocessors/TypographyPreprocessorTest.php @@ -52,11 +52,11 @@ class TypographyPreprocessorTest extends \MailPoetUnitTest { ]; $result = $this->preprocessor->preprocess($blocks, []); $result = $result[0]; - expect($result['innerBlocks'])->count(2); - expect($result['email_attrs'])->equals($expectedEmailAttrs); - expect($result['innerBlocks'][0]['email_attrs'])->equals($expectedEmailAttrs); - expect($result['innerBlocks'][1]['email_attrs'])->equals($expectedEmailAttrs); - expect($result['innerBlocks'][1]['innerBlocks'][0]['email_attrs'])->equals($expectedEmailAttrs); + verify($result['innerBlocks'])->arrayCount(2); + verify($result['email_attrs'])->equals($expectedEmailAttrs); + verify($result['innerBlocks'][0]['email_attrs'])->equals($expectedEmailAttrs); + verify($result['innerBlocks'][1]['email_attrs'])->equals($expectedEmailAttrs); + verify($result['innerBlocks'][1]['innerBlocks'][0]['email_attrs'])->equals($expectedEmailAttrs); } public function testItDoesNotCopyColumnsWidth(): void { @@ -85,11 +85,11 @@ class TypographyPreprocessorTest extends \MailPoetUnitTest { ]]; $result = $this->preprocessor->preprocess($blocks, []); $result = $result[0]; - expect($result['innerBlocks'])->count(2); - expect($result['email_attrs'])->equals(['width' => '640px']); - expect($result['innerBlocks'][0]['email_attrs'])->equals([]); - expect($result['innerBlocks'][1]['email_attrs'])->equals([]); - expect($result['innerBlocks'][1]['innerBlocks'][0]['email_attrs'])->equals([]); + verify($result['innerBlocks'])->arrayCount(2); + verify($result['email_attrs'])->equals(['width' => '640px']); + verify($result['innerBlocks'][0]['email_attrs'])->equals([]); + verify($result['innerBlocks'][1]['email_attrs'])->equals([]); + verify($result['innerBlocks'][1]['innerBlocks'][0]['email_attrs'])->equals([]); } public function testItOverridesColumnsTypography(): void { @@ -182,15 +182,15 @@ class TypographyPreprocessorTest extends \MailPoetUnitTest { $result = $this->preprocessor->preprocess($blocks, []); $child1 = $result[0]; $child2 = $result[1]; - expect($child1['innerBlocks'])->count(2); - expect($child1['email_attrs'])->equals($expectedEmailAttrs1); - expect($child1['innerBlocks'][0]['email_attrs'])->equals($expectedEmailAttrs2); - expect($child1['innerBlocks'][0]['innerBlocks'][0]['email_attrs'])->equals($expectedEmailAttrs2); - expect($child1['innerBlocks'][1]['email_attrs'])->equals($expectedEmailAttrs1); - expect($child1['innerBlocks'][1]['innerBlocks'][0]['email_attrs'])->equals($expectedEmailAttrs1); - expect($child2['innerBlocks'])->count(1); - expect($child2['email_attrs'])->equals([]); - expect($child2['innerBlocks'][0]['email_attrs'])->equals($expectedEmailAttrs2); - expect($child2['innerBlocks'][0]['innerBlocks'][0]['email_attrs'])->equals($expectedEmailAttrs2); + verify($child1['innerBlocks'])->arrayCount(2); + verify($child1['email_attrs'])->equals($expectedEmailAttrs1); + verify($child1['innerBlocks'][0]['email_attrs'])->equals($expectedEmailAttrs2); + verify($child1['innerBlocks'][0]['innerBlocks'][0]['email_attrs'])->equals($expectedEmailAttrs2); + verify($child1['innerBlocks'][1]['email_attrs'])->equals($expectedEmailAttrs1); + verify($child1['innerBlocks'][1]['innerBlocks'][0]['email_attrs'])->equals($expectedEmailAttrs1); + verify($child2['innerBlocks'])->arrayCount(1); + verify($child2['email_attrs'])->equals([]); + verify($child2['innerBlocks'][0]['email_attrs'])->equals($expectedEmailAttrs2); + verify($child2['innerBlocks'][0]['innerBlocks'][0]['email_attrs'])->equals($expectedEmailAttrs2); } }