From eaefdbb97734aa6dc51b1a8a44d4de3a872be850 Mon Sep 17 00:00:00 2001 From: Koji Tanaka Date: Fri, 30 Dec 2022 18:44:36 +0900 Subject: [PATCH] test: Replace assertNotContains() with assertStringNotContainsString() for text assertion. assertNotContains() can no longer be used for text containment assertion. --- .../Case/Console/Command/SchemaShellTest.php | 4 ++-- .../Console/Command/Task/ExtractTaskTest.php | 2 +- .../Console/Command/Task/FixtureTaskTest.php | 10 +++++----- .../Case/Console/Command/Task/TestTaskTest.php | 10 +++++----- .../Case/Console/Command/Task/ViewTaskTest.php | 2 +- lib/Cake/Test/Case/Core/ConfigureTest.php | 2 +- lib/Cake/Test/Case/Error/ErrorHandlerTest.php | 6 +++--- .../Test/Case/Error/ExceptionRendererTest.php | 2 +- lib/Cake/Test/Case/Log/CakeLogTest.php | 2 +- .../Test/Case/Log/Engine/ConsoleLogTest.php | 2 +- .../Model/Datasource/Database/MysqlTest.php | 2 +- .../Model/Datasource/Database/PostgresTest.php | 6 +++--- .../Model/Datasource/Database/SqliteTest.php | 2 +- .../Case/Model/Datasource/DboSourceTest.php | 2 +- .../Test/Case/Network/Email/CakeEmailTest.php | 2 +- .../Test/Case/TestSuite/CakeTestCaseTest.php | 2 +- lib/Cake/Test/Case/Utility/DebuggerTest.php | 4 ++-- .../Test/Case/View/Helper/FormHelperTest.php | 18 +++++++++--------- .../Test/Case/View/HelperCollectionTest.php | 2 +- 19 files changed, 41 insertions(+), 41 deletions(-) diff --git a/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php b/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php index c6ced8e2f..72def74ea 100644 --- a/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php +++ b/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php @@ -419,8 +419,8 @@ class SchemaShellTest extends CakeTestCase { $this->file = new File(TMP . 'tests' . DS . 'schema.php'); $contents = $this->file->read(); - $this->assertNotContains('public $acos = array(', $contents); - $this->assertNotContains('public $aros = array(', $contents); + $this->assertStringNotContainsString('public $acos = array(', $contents); + $this->assertStringNotContainsString('public $aros = array(', $contents); $this->assertStringContainsString('public $aros_acos = array(', $contents); } diff --git a/lib/Cake/Test/Case/Console/Command/Task/ExtractTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ExtractTaskTest.php index cd6fb64fc..53ba40ab6 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ExtractTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ExtractTaskTest.php @@ -450,7 +450,7 @@ class ExtractTaskTest extends CakeTestCase { $this->assertStringContainsString('msgid "Post title is required"', $result); $this->assertStringContainsString('msgid "Post body is required"', $result); $this->assertStringContainsString('msgid "Post body is super required"', $result); - $this->assertNotContains('Plugin/TestPlugin/Model/TestPluginPost.php:validation for field title', $result); + $this->assertStringNotContainsString('Plugin/TestPlugin/Model/TestPluginPost.php:validation for field title', $result); } /** diff --git a/lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php index 075526113..9c5aba39e 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php @@ -448,7 +448,7 @@ class FixtureTaskTest extends CakeTestCase { $this->assertStringContainsString('class ArticleFixture extends CakeTestFixture', $result); $this->assertStringContainsString('public $fields', $result); $this->assertStringContainsString('public $records', $result); - $this->assertNotContains('public $import', $result); + $this->assertStringNotContainsString('public $import', $result); $result = $this->Task->bake('Article', 'comments'); $this->assertStringContainsString('class ArticleFixture extends CakeTestFixture', $result); @@ -457,16 +457,16 @@ class FixtureTaskTest extends CakeTestCase { $result = $this->Task->bake('Article', 'comments', array('records' => true)); $this->assertStringContainsString("public \$import = array('records' => true, 'connection' => 'test');", $result); - $this->assertNotContains('public $records', $result); + $this->assertStringNotContainsString('public $records', $result); $result = $this->Task->bake('Article', 'comments', array('schema' => 'Article')); $this->assertStringContainsString("public \$import = array('model' => 'Article', 'connection' => 'test');", $result); - $this->assertNotContains('public $fields', $result); + $this->assertStringNotContainsString('public $fields', $result); $result = $this->Task->bake('Article', 'comments', array('schema' => 'Article', 'records' => true)); $this->assertStringContainsString("public \$import = array('model' => 'Article', 'records' => true, 'connection' => 'test');", $result); - $this->assertNotContains('public $fields', $result); - $this->assertNotContains('public $records', $result); + $this->assertStringNotContainsString('public $fields', $result); + $this->assertStringNotContainsString('public $records', $result); } /** diff --git a/lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php index d40b9948c..e53693da1 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php @@ -436,12 +436,12 @@ class TestTaskTest extends CakeTestCase { $this->assertStringContainsString("App::uses('TestTaskCommentsController', 'Controller')", $result); $this->assertStringContainsString('class TestTaskCommentsControllerTest extends ControllerTestCase', $result); - $this->assertNotContains('function setUp()', $result); - $this->assertNotContains("\$this->TestTaskComments = new TestTaskCommentsController()", $result); - $this->assertNotContains("\$this->TestTaskComments->constructClasses()", $result); + $this->assertStringNotContainsString('function setUp()', $result); + $this->assertStringNotContainsString("\$this->TestTaskComments = new TestTaskCommentsController()", $result); + $this->assertStringNotContainsString("\$this->TestTaskComments->constructClasses()", $result); - $this->assertNotContains('function tearDown()', $result); - $this->assertNotContains('unset($this->TestTaskComments)', $result); + $this->assertStringNotContainsString('function tearDown()', $result); + $this->assertStringNotContainsString('unset($this->TestTaskComments)', $result); $this->assertStringContainsString("'app.test_task_article'", $result); $this->assertStringContainsString("'app.test_task_comment'", $result); diff --git a/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php index c7dac2a7f..f9f2947cb 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php @@ -359,7 +359,7 @@ class ViewTaskTest extends CakeTestCase { $path = APP . 'Plugin' . DS . 'TestTest' . DS . 'View' . DS . 'ViewTaskComments' . DS . 'view.ctp'; $result = $this->Task->getContent('index'); - $this->assertNotContains('List Test Test.view Task Articles', $result); + $this->assertStringNotContainsString('List Test Test.view Task Articles', $result); $this->Task->expects($this->once()) ->method('createFile') diff --git a/lib/Cake/Test/Case/Core/ConfigureTest.php b/lib/Cake/Test/Case/Core/ConfigureTest.php index ca92df85c..cf769a02a 100644 --- a/lib/Cake/Test/Case/Core/ConfigureTest.php +++ b/lib/Cake/Test/Case/Core/ConfigureTest.php @@ -524,7 +524,7 @@ class ConfigureTest extends CakeTestCase { $this->assertStringContainsString('assertStringContainsString('$config = ', $result); $this->assertStringContainsString('Error', $result); - $this->assertNotContains('debug', $result); + $this->assertStringNotContainsString('debug', $result); if (file_exists(TMP . 'config_test.php')) { unlink(TMP . 'config_test.php'); diff --git a/lib/Cake/Test/Case/Error/ErrorHandlerTest.php b/lib/Cake/Test/Case/Error/ErrorHandlerTest.php index f4ad98789..9fc619fc8 100644 --- a/lib/Cake/Test/Case/Error/ErrorHandlerTest.php +++ b/lib/Cake/Test/Case/Error/ErrorHandlerTest.php @@ -269,7 +269,7 @@ class ErrorHandlerTest extends CakeTestCase { $this->assertMatchesRegularExpression('/Fooled you!/', $result, 'message missing.'); $log = file(LOGS . 'error.log'); - $this->assertNotContains('[NotFoundException] Kaboom!', $log[0], 'message should not be logged.'); + $this->assertStringNotContainsString('[NotFoundException] Kaboom!', $log[0], 'message should not be logged.'); $this->assertStringContainsString('[ForbiddenException] Fooled you!', $log[0], 'message missing.'); } @@ -318,8 +318,8 @@ class ErrorHandlerTest extends CakeTestCase { Configure::write('debug', 0); ErrorHandler::handleFatalError(E_ERROR, 'Something wrong', __FILE__, $line); $result = ob_get_clean(); - $this->assertNotContains('Something wrong', $result, 'message must not appear.'); - $this->assertNotContains(__FILE__, $result, 'filename must not appear.'); + $this->assertStringNotContainsString('Something wrong', $result, 'message must not appear.'); + $this->assertStringNotContainsString(__FILE__, $result, 'filename must not appear.'); $this->assertStringContainsString('An Internal Error Has Occurred', $result); } diff --git a/lib/Cake/Test/Case/Error/ExceptionRendererTest.php b/lib/Cake/Test/Case/Error/ExceptionRendererTest.php index 4caf69791..6309063d1 100644 --- a/lib/Cake/Test/Case/Error/ExceptionRendererTest.php +++ b/lib/Cake/Test/Case/Error/ExceptionRendererTest.php @@ -362,7 +362,7 @@ class ExceptionRendererTest extends CakeTestCase { $result = ob_get_clean(); $this->assertEquals('error500', $ExceptionRenderer->method, 'incorrect method coercion.'); - $this->assertNotContains('foul ball.', $result, 'Text should no show up.'); + $this->assertStringNotContainsString('foul ball.', $result, 'Text should no show up.'); $this->assertStringContainsString('Internal Error', $result, 'Generic message only.'); } diff --git a/lib/Cake/Test/Case/Log/CakeLogTest.php b/lib/Cake/Test/Case/Log/CakeLogTest.php index 6d30c864b..53becfe65 100644 --- a/lib/Cake/Test/Case/Log/CakeLogTest.php +++ b/lib/Cake/Test/Case/Log/CakeLogTest.php @@ -734,7 +734,7 @@ class CakeLogTest extends CakeTestCase { CakeLog::write('eggs', $testMessage); CakeLog::defaultLevels(); $contents = file_get_contents(LOGS . 'spam.log'); - $this->assertNotContains('Eggs: ' . $testMessage, $contents); + $this->assertStringNotContainsString('Eggs: ' . $testMessage, $contents); $contents = file_get_contents(LOGS . 'eggs.log'); $this->assertStringContainsString('Eggs: ' . $testMessage, $contents); diff --git a/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php b/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php index 1ba94b3a1..4de920e90 100644 --- a/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php +++ b/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php @@ -125,7 +125,7 @@ class ConsoleLogTest extends CakeTestCase { $this->assertTrue(file_exists(LOGS . 'error.log'), 'error.log missing'); $this->assertTrue(file_exists(LOGS . 'debug.log'), 'debug.log missing'); $logOutput = file_get_contents(LOGS . 'error.log'); - $this->assertNotContains($message, $logOutput); + $this->assertStringNotContainsString($message, $logOutput); $logOutput = file_get_contents(LOGS . 'debug.log'); $this->assertStringContainsString($message, $logOutput); } diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php index 10a4d70d6..67e8ba929 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php @@ -1027,7 +1027,7 @@ SQL; ); $result = $this->Dbo->createSchema($schema, 'no_indexes'); $this->assertStringContainsString('PRIMARY KEY (`id`)', $result); - $this->assertNotContains('UNIQUE KEY', $result); + $this->assertStringNotContainsString('UNIQUE KEY', $result); $schema->tables = array( 'primary_index' => array( diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php index d68f5275d..415237017 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php @@ -866,8 +866,8 @@ class PostgresTest extends CakeTestCase { )); $this->assertStringContainsString('RENAME "title" TO "subject";', $query); $this->assertStringContainsString('ALTER COLUMN "subject" TYPE', $query); - $this->assertNotContains(";\n\tALTER COLUMN \"subject\" TYPE", $query); - $this->assertNotContains('ALTER COLUMN "title" TYPE "subject"', $query); + $this->assertStringNotContainsString(";\n\tALTER COLUMN \"subject\" TYPE", $query); + $this->assertStringNotContainsString('ALTER COLUMN "title" TYPE "subject"', $query); } /** @@ -1141,7 +1141,7 @@ class PostgresTest extends CakeTestCase { $result = $db->limit(10, 300000000000000000000000000000); $scientificNotation = sprintf('%.1E', 300000000000000000000000000000); - $this->assertNotContains($scientificNotation, $result); + $this->assertStringNotContainsString($scientificNotation, $result); } /** diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php index 86317eeb0..09d552e3a 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php @@ -596,7 +596,7 @@ SQL; $result = $db->limit(10, 300000000000000000000000000000); $scientificNotation = sprintf('%.1E', 300000000000000000000000000000); - $this->assertNotContains($scientificNotation, $result); + $this->assertStringNotContainsString($scientificNotation, $result); } /** diff --git a/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php b/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php index 2a31f0184..75744b4e9 100644 --- a/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php @@ -1783,7 +1783,7 @@ class DboSourceTest extends CakeTestCase { $result = $db->limit(10, 300000000000000000000000000000); $scientificNotation = sprintf('%.1E', 300000000000000000000000000000); - $this->assertNotContains($scientificNotation, $result); + $this->assertStringNotContainsString($scientificNotation, $result); } /** diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index 2d12c2e5a..da70d7d4c 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -1462,7 +1462,7 @@ class CakeEmailTest extends CakeTestCase { $result = $this->CakeEmail->send('message body.'); $this->assertStringContainsString('message body.', $result['message']); - $this->assertNotContains('This email was sent using the CakePHP Framework', $result['message']); + $this->assertStringNotContainsString('This email was sent using the CakePHP Framework', $result['message']); } /** diff --git a/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php b/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php index f7adc7208..554926d19 100644 --- a/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php +++ b/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php @@ -381,7 +381,7 @@ class CakeTestCaseTest extends CakeTestCase { public function testAssertTextContains() { $stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!"; $this->assertStringContainsString("different", $stringDirty); - $this->assertNotContains("different\rline", $stringDirty); + $this->assertStringNotContainsString("different\rline", $stringDirty); $this->assertTextContains("different\rline", $stringDirty); } diff --git a/lib/Cake/Test/Case/Utility/DebuggerTest.php b/lib/Cake/Test/Case/Utility/DebuggerTest.php index 7d7a96457..fb63448a6 100644 --- a/lib/Cake/Test/Case/Utility/DebuggerTest.php +++ b/lib/Cake/Test/Case/Utility/DebuggerTest.php @@ -169,7 +169,7 @@ class DebuggerTest extends CakeTestCase { $b = $a['']; $result = ob_get_clean(); - $this->assertNotContains('