Replace expect()->startsWith() with verify()->stringStartsWith()

codeception/verify 2.1 removed support for expect()->startsWith() so we need
to replace it with verify()->stringStartsWith().

[MAILPOET-5664]
This commit is contained in:
Rodrigo Primo
2023-10-18 16:38:52 -03:00
committed by David Remer
parent a1f57361c5
commit 4bc4e9b254
10 changed files with 11 additions and 11 deletions

View File

@@ -90,7 +90,7 @@ class DynamicSegmentsResponseBuilderTest extends \MailPoetTest {
verify($response[0]['name'])->equals($name); verify($response[0]['name'])->equals($name);
verify($response[0]['description'])->equals($description); verify($response[0]['description'])->equals($description);
verify($response[0]['type'])->equals(SegmentEntity::TYPE_DYNAMIC); verify($response[0]['type'])->equals(SegmentEntity::TYPE_DYNAMIC);
expect($response[0]['subscribers_url'])->startsWith('http'); verify($response[0]['subscribers_url'])->stringStartsWith('http');
verify($response[0]['count_all'])->equals(1); verify($response[0]['count_all'])->equals(1);
verify($response[0]['count_subscribed'])->equals(1); verify($response[0]['count_subscribed'])->equals(1);

View File

@@ -54,7 +54,7 @@ class SegmentsResponseBuilderTest extends \MailPoetTest {
verify($response)->isArray(); verify($response)->isArray();
verify($response[0]['name'])->equals($name); verify($response[0]['name'])->equals($name);
verify($response[0]['type'])->equals(SegmentEntity::TYPE_DEFAULT); verify($response[0]['type'])->equals(SegmentEntity::TYPE_DEFAULT);
expect($response[0]['subscribers_url'])->startsWith('http'); verify($response[0]['subscribers_url'])->stringStartsWith('http');
verify($response[0]['subscribers_count']['subscribed'])->equals('1'); verify($response[0]['subscribers_count']['subscribed'])->equals('1');
} }
} }

View File

@@ -135,7 +135,7 @@ class FormsTest extends \MailPoetTest {
wp_set_current_user(0); wp_set_current_user(0);
$response = $this->endpoint->saveEditor($form); $response = $this->endpoint->saveEditor($form);
verify($response->status)->equals(APIResponse::STATUS_FORBIDDEN); verify($response->status)->equals(APIResponse::STATUS_FORBIDDEN);
expect($response->errors[0]['message'])->startsWith('Only administrator can'); verify($response->errors[0]['message'])->stringStartsWith('Only administrator can');
} }
public function testItCanExtractListsFromListSelectionBlock() { public function testItCanExtractListsFromListSelectionBlock() {

View File

@@ -264,7 +264,7 @@ class CronHelperTest extends \MailPoetTest {
$this->cronHelper->enforceExecutionLimit($time - $this->cronHelper->getDaemonExecutionLimit()); $this->cronHelper->enforceExecutionLimit($time - $this->cronHelper->getDaemonExecutionLimit());
self::fail('Execution limit exception not thrown.'); self::fail('Execution limit exception not thrown.');
} catch (\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->startsWith('The maximum execution time'); verify($e->getMessage())->stringStartsWith('The maximum execution time');
} }
} }

View File

@@ -221,7 +221,7 @@ class CronWorkerRunnerTest extends \MailPoetTest {
$cronWorkerRunner->run($worker); $cronWorkerRunner->run($worker);
self::fail('Maximum execution time limit exception was not thrown.'); self::fail('Maximum execution time limit exception was not thrown.');
} catch (\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->startsWith('The maximum execution time'); verify($e->getMessage())->stringStartsWith('The maximum execution time');
} }
} }

View File

@@ -119,7 +119,7 @@ class SchedulerTest extends \MailPoetTest {
$scheduler->process(microtime(true) - $this->cronHelper->getDaemonExecutionLimit()); $scheduler->process(microtime(true) - $this->cronHelper->getDaemonExecutionLimit());
self::fail('Maximum execution time limit exception was not thrown.'); self::fail('Maximum execution time limit exception was not thrown.');
} catch (\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->startsWith('The maximum execution time'); verify($e->getMessage())->stringStartsWith('The maximum execution time');
} }
} }

View File

@@ -92,7 +92,7 @@ class SubscribersLastEngagementTest extends \MailPoetTest {
$exception = $e; $exception = $e;
} }
$this->assertInstanceOf(\Exception::class, $exception); $this->assertInstanceOf(\Exception::class, $exception);
expect($exception->getMessage())->startsWith('The maximum execution time'); verify($exception->getMessage())->stringStartsWith('The maximum execution time');
$result = $this->worker->processTaskStrategy($task, microtime(true)); $result = $this->worker->processTaskStrategy($task, microtime(true));
verify($result)->true(); verify($result)->true();
} }

View File

@@ -19,7 +19,7 @@ class ThumbnailSaverTest extends \MailPoetTest {
$thumbnailUrl = $template->getThumbnail(); $thumbnailUrl = $template->getThumbnail();
verify($thumbnailUrl)->notEmpty(); verify($thumbnailUrl)->notEmpty();
expect($thumbnailUrl)->string(); expect($thumbnailUrl)->string();
expect($thumbnailUrl)->startsWith(Env::$tempUrl); verify($thumbnailUrl)->stringStartsWith(Env::$tempUrl);
verify($thumbnailUrl)->stringContainsString(ThumbnailSaver::THUMBNAIL_DIRECTORY); verify($thumbnailUrl)->stringContainsString(ThumbnailSaver::THUMBNAIL_DIRECTORY);
[,$fileName] = explode(ThumbnailSaver::THUMBNAIL_DIRECTORY, (string)$thumbnailUrl); [,$fileName] = explode(ThumbnailSaver::THUMBNAIL_DIRECTORY, (string)$thumbnailUrl);
$file = Env::$tempPath . '/' . ThumbnailSaver::THUMBNAIL_DIRECTORY . $fileName; $file = Env::$tempPath . '/' . ThumbnailSaver::THUMBNAIL_DIRECTORY . $fileName;
@@ -36,7 +36,7 @@ class ThumbnailSaverTest extends \MailPoetTest {
// Base url was updated back to initial value // Base url was updated back to initial value
$thumbnailUrl = $template->getThumbnail(); $thumbnailUrl = $template->getThumbnail();
expect($thumbnailUrl)->string(); expect($thumbnailUrl)->string();
expect($thumbnailUrl)->startsWith(Env::$tempUrl); verify($thumbnailUrl)->stringStartsWith(Env::$tempUrl);
[,$fileName] = explode(ThumbnailSaver::THUMBNAIL_DIRECTORY, (string)$thumbnailUrl); [,$fileName] = explode(ThumbnailSaver::THUMBNAIL_DIRECTORY, (string)$thumbnailUrl);
// File is still the same // File is still the same
expect($thumbnailUrl)->endsWith($fileName); expect($thumbnailUrl)->endsWith($fileName);

View File

@@ -18,7 +18,7 @@ class HeadingTest extends \MailPoetUnitTest {
public function testItShouldRenderHeading() { public function testItShouldRenderHeading() {
$html = $this->heading->render([]); $html = $this->heading->render([]);
expect($html)->startsWith('<h2'); verify($html)->stringStartsWith('<h2');
} }
public function testItShouldRenderContent() { public function testItShouldRenderContent() {

View File

@@ -18,7 +18,7 @@ class ParagraphTest extends \MailPoetUnitTest {
public function testItShouldRenderParagraph() { public function testItShouldRenderParagraph() {
$html = $this->paragraph->render([]); $html = $this->paragraph->render([]);
expect($html)->startsWith('<p'); verify($html)->stringStartsWith('<p');
} }
public function testItShouldRenderContent() { public function testItShouldRenderContent() {