Skip to content

Commit 99a337b

Browse files
committed
Replace assertContains for string haystacks (deprecated)
1 parent ed5faf4 commit 99a337b

17 files changed

Lines changed: 152 additions & 152 deletions

tests/system/Autoloader/AutoloaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function testMissingFile()
125125
public function testInitializeException()
126126
{
127127
$this->expectException('InvalidArgumentException');
128-
$this->expectExceptionMessage('Config array must contain either the 'psr4' key or the 'classmap' key.');
128+
$this->expectExceptionMessage("Config array must contain either the 'psr4' key or the 'classmap' key.");
129129

130130
$config = new Autoload();
131131
$config->classmap = [];

tests/system/CLI/CommandRunnerTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public function testGoodCommand()
5959
$result = CITestStreamFilter::$buffer;
6060

6161
// make sure the result looks like a command list
62-
$this->assertContains('Lists the available commands.', $result);
63-
$this->assertContains('Displays basic usage information.', $result);
62+
$this->assertStringContainsString('Lists the available commands.', $result);
63+
$this->assertStringContainsString('Displays basic usage information.', $result);
6464
}
6565

6666
public function testDefaultCommand()
@@ -69,8 +69,8 @@ public function testDefaultCommand()
6969
$result = CITestStreamFilter::$buffer;
7070

7171
// make sure the result looks like basic help
72-
$this->assertContains('Displays basic usage information.', $result);
73-
$this->assertContains('help command_name', $result);
72+
$this->assertStringContainsString('Displays basic usage information.', $result);
73+
$this->assertStringContainsString('help command_name', $result);
7474
}
7575

7676
public function testHelpCommand()
@@ -79,8 +79,8 @@ public function testHelpCommand()
7979
$result = CITestStreamFilter::$buffer;
8080

8181
// make sure the result looks like basic help
82-
$this->assertContains('Displays basic usage information.', $result);
83-
$this->assertContains('help command_name', $result);
82+
$this->assertStringContainsString('Displays basic usage information.', $result);
83+
$this->assertStringContainsString('help command_name', $result);
8484
}
8585

8686
public function testHelpCommandDetails()
@@ -89,9 +89,9 @@ public function testHelpCommandDetails()
8989
$result = CITestStreamFilter::$buffer;
9090

9191
// make sure the result looks like more detailed help
92-
$this->assertContains('Description:', $result);
93-
$this->assertContains('Usage:', $result);
94-
$this->assertContains('Options:', $result);
92+
$this->assertStringContainsString('Description:', $result);
93+
$this->assertStringContainsString('Usage:', $result);
94+
$this->assertStringContainsString('Options:', $result);
9595
}
9696

9797
public function testCommandProperties()
@@ -111,7 +111,7 @@ public function testEmptyCommand()
111111
$result = CITestStreamFilter::$buffer;
112112

113113
// make sure the result looks like a command list
114-
$this->assertContains('Lists the available commands.', $result);
114+
$this->assertStringContainsString('Lists the available commands.', $result);
115115
}
116116

117117
public function testBadCommand()
@@ -122,7 +122,7 @@ public function testBadCommand()
122122
stream_filter_remove($this->error_filter);
123123

124124
// make sure the result looks like a command list
125-
$this->assertContains('Command "bogus" not found', $result);
125+
$this->assertStringContainsString('Command "bogus" not found', $result);
126126
}
127127

128128
}

tests/system/CLI/ConsoleTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ public function testRun()
6868
ob_end_clean();
6969

7070
// make sure the result looks like a command list
71-
$this->assertContains('Lists the available commands.', $result);
72-
$this->assertContains('Displays basic usage information.', $result);
71+
$this->assertStringContainsString('Lists the available commands.', $result);
72+
$this->assertStringContainsString('Displays basic usage information.', $result);
7373
}
7474

7575
}

tests/system/CodeIgniterTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function testRunDefaultRoute()
5555
$this->codeigniter->useSafeOutput(true)->run();
5656
$output = ob_get_clean();
5757

58-
$this->assertContains('Welcome to CodeIgniter', $output);
58+
$this->assertStringContainsString('Welcome to CodeIgniter', $output);
5959
}
6060

6161
//--------------------------------------------------------------------
@@ -71,7 +71,7 @@ public function testRunEmptyDefaultRoute()
7171
$this->codeigniter->useSafeOutput(true)->run();
7272
$output = ob_get_clean();
7373

74-
$this->assertContains('Welcome to CodeIgniter', $output);
74+
$this->assertStringContainsString('Welcome to CodeIgniter', $output);
7575
}
7676

7777
//--------------------------------------------------------------------
@@ -97,7 +97,7 @@ public function testRunClosureRoute()
9797
$this->codeigniter->useSafeOutput(true)->run();
9898
$output = ob_get_clean();
9999

100-
$this->assertContains('You want to see "about" page.', $output);
100+
$this->assertStringContainsString('You want to see "about" page.', $output);
101101
}
102102

103103
//--------------------------------------------------------------------
@@ -121,7 +121,7 @@ public function testRun404Override()
121121
$this->codeigniter->useSafeOutput(true)->run();
122122
$output = ob_get_clean();
123123

124-
$this->assertContains('Welcome to CodeIgniter', $output);
124+
$this->assertStringContainsString('Welcome to CodeIgniter', $output);
125125
}
126126

127127
//--------------------------------------------------------------------
@@ -147,7 +147,7 @@ public function testRun404OverrideByClosure()
147147
$this->codeigniter->useSafeOutput(true)->run($routes);
148148
$output = ob_get_clean();
149149

150-
$this->assertContains('404 Override by Closure.', $output);
150+
$this->assertStringContainsString('404 Override by Closure.', $output);
151151
}
152152

153153
//--------------------------------------------------------------------
@@ -173,7 +173,7 @@ public function testControllersCanReturnString()
173173
$this->codeigniter->useSafeOutput(true)->run();
174174
$output = ob_get_clean();
175175

176-
$this->assertContains('You want to see "about" page.', $output);
176+
$this->assertStringContainsString('You want to see "about" page.', $output);
177177
}
178178

179179
//--------------------------------------------------------------------
@@ -201,7 +201,7 @@ public function testControllersCanReturnResponseObject()
201201
$this->codeigniter->useSafeOutput(true)->run();
202202
$output = ob_get_clean();
203203

204-
$this->assertContains("You want to see 'about' page.", $output);
204+
$this->assertStringContainsString("You want to see 'about' page.", $output);
205205
}
206206

207207
//--------------------------------------------------------------------
@@ -237,7 +237,7 @@ public function testRoutesIsEmpty()
237237
$this->codeigniter->useSafeOutput(true)->run();
238238
$output = ob_get_clean();
239239

240-
$this->assertContains('Welcome to CodeIgniter', $output);
240+
$this->assertStringContainsString('Welcome to CodeIgniter', $output);
241241
}
242242

243243
public function testTransfersCorrectHTTPVersion()
@@ -271,6 +271,6 @@ public function testIgnoringErrorSuppressedByAt()
271271
$this->codeigniter->useSafeOutput(true)->run();
272272
$output = ob_get_clean();
273273

274-
$this->assertContains('Welcome to CodeIgniter', $output);
274+
$this->assertStringContainsString('Welcome to CodeIgniter', $output);
275275
}
276276
}

tests/system/Commands/CommandsTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public function testHelpCommand()
6161
$result = CITestStreamFilter::$buffer;
6262

6363
// make sure the result looks like a command list
64-
$this->assertContains('Displays basic usage information.', $result);
65-
$this->assertContains('command_name', $result);
64+
$this->assertStringContainsString('Displays basic usage information.', $result);
65+
$this->assertStringContainsString('command_name', $result);
6666
}
6767

6868
public function testListCommands()
@@ -71,16 +71,16 @@ public function testListCommands()
7171
$result = CITestStreamFilter::$buffer;
7272

7373
// make sure the result looks like a command list
74-
$this->assertContains('Lists the available commands.', $result);
75-
$this->assertContains('Displays basic usage information.', $result);
74+
$this->assertStringContainsString('Lists the available commands.', $result);
75+
$this->assertStringContainsString('Displays basic usage information.', $result);
7676
}
7777

7878
public function testCustomCommand()
7979
{
8080
$this->runner->index(['app:info']);
8181
$result = CITestStreamFilter::$buffer;
8282

83-
$this->assertContains('CI Version:', $result);
83+
$this->assertStringContainsString('CI Version:', $result);
8484
}
8585

8686
public function testShowError()
@@ -91,7 +91,7 @@ public function testShowError()
9191

9292
$command->helpme();
9393
$result = CITestStreamFilter::$buffer;
94-
$this->assertContains('Displays basic usage information.', $result);
94+
$this->assertStringContainsString('Displays basic usage information.', $result);
9595
}
9696

9797
public function testCommandCall()
@@ -105,7 +105,7 @@ public function testCommandCall()
105105
$result = CITestStreamFilter::$buffer;
106106
stream_filter_remove($this->error_filter);
107107

108-
$this->assertContains('Invalid background color:', $result);
108+
$this->assertStringContainsString('Invalid background color:', $result);
109109
}
110110

111111
public function testNonexistantCommand()
@@ -116,7 +116,7 @@ public function testNonexistantCommand()
116116
$this->runner->index(['app:oops']);
117117
$result = CITestStreamFilter::$buffer;
118118

119-
$this->assertContains('not found', $result);
119+
$this->assertStringContainsString('not found', $result);
120120
}
121121

122122
public function testAbstractCommand()
@@ -127,27 +127,27 @@ public function testAbstractCommand()
127127
$this->runner->index(['app:pablo']);
128128
$result = CITestStreamFilter::$buffer;
129129

130-
$this->assertContains('not found', $result);
130+
$this->assertStringContainsString('not found', $result);
131131
}
132132

133133
public function testNamespacesCommand()
134134
{
135135
$this->runner->index(['namespaces']);
136136
$result = CITestStreamFilter::$buffer;
137137

138-
$this->assertContains('| Namespace', $result);
139-
$this->assertContains('| Config', $result);
140-
$this->assertContains('| Yes', $result);
138+
$this->assertStringContainsString('| Namespace', $result);
139+
$this->assertStringContainsString('| Config', $result);
140+
$this->assertStringContainsString('| Yes', $result);
141141
}
142142

143143
public function testRoutesCommand()
144144
{
145145
$this->runner->index(['routes']);
146146
$result = CITestStreamFilter::$buffer;
147147

148-
$this->assertContains('| Route', $result);
149-
$this->assertContains('| testing', $result);
150-
$this->assertContains('\\TestController::index', $result);
148+
$this->assertStringContainsString('| Route', $result);
149+
$this->assertStringContainsString('| testing', $result);
150+
$this->assertStringContainsString('\\TestController::index', $result);
151151
}
152152

153153
}

tests/system/Commands/SessionsCommandsTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ public function testCreateMigrationCommand()
7070
// make sure we end up with a migration class in the right place
7171
// or at least that we claim to have done so
7272
// separate assertions avoid console color codes
73-
$this->assertContains('Created file:', $result);
74-
$this->assertContains('APPPATH/Database/Migrations/', $result);
75-
$this->assertContains('_create_ci_sessions_table.php', $result);
73+
$this->assertStringContainsString('Created file:', $result);
74+
$this->assertStringContainsString('APPPATH/Database/Migrations/', $result);
75+
$this->assertStringContainsString('_create_ci_sessions_table.php', $result);
7676

7777
$this->result = $result;
7878
}
@@ -92,9 +92,9 @@ public function testOverriddenCreateMigrationCommand()
9292
$result = CITestStreamFilter::$buffer;
9393

9494
// make sure we end up with a migration class in the right place
95-
$this->assertContains('Created file:', $result);
96-
$this->assertContains('APPPATH/Database/Migrations/', $result);
97-
$this->assertContains('_create_mygoodies_table.php', $result);
95+
$this->assertStringContainsString('Created file:', $result);
96+
$this->assertStringContainsString('APPPATH/Database/Migrations/', $result);
97+
$this->assertStringContainsString('_create_mygoodies_table.php', $result);
9898

9999
$this->result = $result;
100100
}

tests/system/CommonFunctionsTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function testView()
128128
'bar' => 'baz',
129129
];
130130
$expected = '<h1>bar</h1>';
131-
$this->assertContains($expected, view('\Tests\Support\View\Views\simple', $data, []));
131+
$this->assertStringContainsString($expected, view('\Tests\Support\View\Views\simple', $data, []));
132132
}
133133

134134
public function testViewSavedData()
@@ -138,8 +138,8 @@ public function testViewSavedData()
138138
'bar' => 'baz',
139139
];
140140
$expected = '<h1>bar</h1>';
141-
$this->assertContains($expected, view('\Tests\Support\View\Views\simple', $data, ['saveData' => true]));
142-
$this->assertContains($expected, view('\Tests\Support\View\Views\simple'));
141+
$this->assertStringContainsString($expected, view('\Tests\Support\View\Views\simple', $data, ['saveData' => true]));
142+
$this->assertStringContainsString($expected, view('\Tests\Support\View\Views\simple'));
143143
}
144144

145145
// ------------------------------------------------------------------------
@@ -263,12 +263,12 @@ public function testHash()
263263

264264
public function testCSRFField()
265265
{
266-
$this->assertContains('<input type="hidden" ', csrf_field());
266+
$this->assertStringContainsString('<input type="hidden" ', csrf_field());
267267
}
268268

269269
public function testCSRFMeta()
270270
{
271-
$this->assertContains('<meta name="X-CSRF-TOKEN" ', csrf_meta());
271+
$this->assertStringContainsString('<meta name="X-CSRF-TOKEN" ', csrf_meta());
272272
}
273273

274274
// ------------------------------------------------------------------------

tests/system/Filters/HoneypotTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function testAfter()
8989

9090
$this->response->setBody('<form></form>');
9191
$this->response = $filters->run($uri, 'after');
92-
$this->assertContains($this->honey->name, $this->response->getBody());
92+
$this->assertStringContainsString($this->honey->name, $this->response->getBody());
9393
}
9494

9595
//--------------------------------------------------------------------

0 commit comments

Comments
 (0)