Skip to content

Commit 5c5d19e

Browse files
committed
Use assertStringContainsString when needed
1 parent 48a3fcb commit 5c5d19e

16 files changed

+76
-76
lines changed

Tests/Command/RouterDebugCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function testDebugAllRoutes()
2727
$ret = $tester->execute(['name' => null], ['decorated' => false]);
2828

2929
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
30-
$this->assertContains('Name Method Scheme Host Path', $tester->getDisplay());
30+
$this->assertStringContainsString('Name Method Scheme Host Path', $tester->getDisplay());
3131
}
3232

3333
public function testDebugSingleRoute()
@@ -36,7 +36,7 @@ public function testDebugSingleRoute()
3636
$ret = $tester->execute(['name' => 'foo'], ['decorated' => false]);
3737

3838
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
39-
$this->assertContains('Route Name | foo', $tester->getDisplay());
39+
$this->assertStringContainsString('Route Name | foo', $tester->getDisplay());
4040
}
4141

4242
public function testDebugInvalidRoute()

Tests/Command/RouterMatchCommandTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function testWithMatchPath()
2929
$ret = $tester->execute(['path_info' => '/foo', 'foo'], ['decorated' => false]);
3030

3131
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
32-
$this->assertContains('Route Name | foo', $tester->getDisplay());
32+
$this->assertStringContainsString('Route Name | foo', $tester->getDisplay());
3333
}
3434

3535
public function testWithNotMatchPath()
@@ -38,7 +38,7 @@ public function testWithNotMatchPath()
3838
$ret = $tester->execute(['path_info' => '/test', 'foo'], ['decorated' => false]);
3939

4040
$this->assertEquals(1, $ret, 'Returns 1 in case of failure');
41-
$this->assertContains('None of the routes match the path "/test"', $tester->getDisplay());
41+
$this->assertStringContainsString('None of the routes match the path "/test"', $tester->getDisplay());
4242
}
4343

4444
/**
@@ -56,7 +56,7 @@ public function testLegacyMatchCommand()
5656

5757
$tester->execute(['path_info' => '/']);
5858

59-
$this->assertContains('None of the routes match the path "/"', $tester->getDisplay());
59+
$this->assertStringContainsString('None of the routes match the path "/"', $tester->getDisplay());
6060
}
6161

6262
/**

Tests/Command/TranslationDebugCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public function testLegacyDebugCommand()
239239
$tester = new CommandTester($application->find('debug:translation'));
240240
$tester->execute(['locale' => 'en']);
241241

242-
$this->assertContains('No defined or extracted', $tester->getDisplay());
242+
$this->assertStringContainsString('No defined or extracted', $tester->getDisplay());
243243
}
244244

245245
private function getBundle($path)

Tests/Command/TranslationUpdateCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public function testLegacyUpdateCommand()
231231
$tester = new CommandTester($application->find('translation:update'));
232232
$tester->execute(['locale' => 'en']);
233233

234-
$this->assertContains('You must choose one of --force or --dump-messages', $tester->getDisplay());
234+
$this->assertStringContainsString('You must choose one of --force or --dump-messages', $tester->getDisplay());
235235
}
236236

237237
private function getBundle($path)

Tests/Command/YamlLintCommandTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testLintCorrectFile()
4141
);
4242

4343
$this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success');
44-
$this->assertContains('OK', trim($tester->getDisplay()));
44+
$this->assertStringContainsString('OK', trim($tester->getDisplay()));
4545
}
4646

4747
public function testLintIncorrectFile()
@@ -55,7 +55,7 @@ public function testLintIncorrectFile()
5555
$tester->execute(['filename' => $filename], ['decorated' => false]);
5656

5757
$this->assertEquals(1, $tester->getStatusCode(), 'Returns 1 in case of error');
58-
$this->assertContains('Unable to parse at line 3 (near "bar").', trim($tester->getDisplay()));
58+
$this->assertStringContainsString('Unable to parse at line 3 (near "bar").', trim($tester->getDisplay()));
5959
}
6060

6161
public function testLintFileNotReadable()
@@ -106,7 +106,7 @@ public function testLintFilesFromBundleDirectory()
106106
);
107107

108108
$this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success');
109-
$this->assertContains('[OK] All 0 YAML files contain valid syntax', trim($tester->getDisplay()));
109+
$this->assertStringContainsString('[OK] All 0 YAML files contain valid syntax', trim($tester->getDisplay()));
110110
}
111111

112112
/**

Tests/Console/ApplicationTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ public function testRunOnlyWarnsOnUnregistrableCommand()
160160
$output = $tester->getDisplay();
161161

162162
$this->assertSame(0, $tester->getStatusCode());
163-
$this->assertContains('Some commands could not be registered:', $output);
164-
$this->assertContains('throwing', $output);
165-
$this->assertContains('fine', $output);
163+
$this->assertStringContainsString('Some commands could not be registered:', $output);
164+
$this->assertStringContainsString('throwing', $output);
165+
$this->assertStringContainsString('fine', $output);
166166
}
167167

168168
public function testRegistrationErrorsAreDisplayedOnCommandNotFound()
@@ -188,8 +188,8 @@ public function testRegistrationErrorsAreDisplayedOnCommandNotFound()
188188
$output = $tester->getDisplay();
189189

190190
$this->assertSame(1, $tester->getStatusCode());
191-
$this->assertContains('Some commands could not be registered:', $output);
192-
$this->assertContains('Command "fine" is not defined.', $output);
191+
$this->assertStringContainsString('Some commands could not be registered:', $output);
192+
$this->assertStringContainsString('Command "fine" is not defined.', $output);
193193
}
194194

195195
private function getKernel(array $bundles, $useDispatcher = false)

Tests/Controller/ControllerNameParserTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ public function testInvalidBundleName($bundleName, $suggestedBundleName)
127127

128128
if (false === $suggestedBundleName) {
129129
// make sure we don't have a suggestion
130-
$this->assertNotContains('Did you mean', $e->getMessage());
130+
$this->assertStringNotContainsString('Did you mean', $e->getMessage());
131131
} else {
132-
$this->assertContains(sprintf('Did you mean "%s"', $suggestedBundleName), $e->getMessage());
132+
$this->assertStringContainsString(sprintf('Did you mean "%s"', $suggestedBundleName), $e->getMessage());
133133
}
134134
}
135135
}

Tests/Controller/ControllerTraitTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ public function testFile()
186186
if ($response->headers->get('content-type')) {
187187
$this->assertSame('text/x-php', $response->headers->get('content-type'));
188188
}
189-
$this->assertContains(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition'));
190-
$this->assertContains(basename(__FILE__), $response->headers->get('content-disposition'));
189+
$this->assertStringContainsString(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition'));
190+
$this->assertStringContainsString(basename(__FILE__), $response->headers->get('content-disposition'));
191191
}
192192

193193
public function testFileAsInline()
@@ -202,8 +202,8 @@ public function testFileAsInline()
202202
if ($response->headers->get('content-type')) {
203203
$this->assertSame('text/x-php', $response->headers->get('content-type'));
204204
}
205-
$this->assertContains(ResponseHeaderBag::DISPOSITION_INLINE, $response->headers->get('content-disposition'));
206-
$this->assertContains(basename(__FILE__), $response->headers->get('content-disposition'));
205+
$this->assertStringContainsString(ResponseHeaderBag::DISPOSITION_INLINE, $response->headers->get('content-disposition'));
206+
$this->assertStringContainsString(basename(__FILE__), $response->headers->get('content-disposition'));
207207
}
208208

209209
public function testFileWithOwnFileName()
@@ -219,8 +219,8 @@ public function testFileWithOwnFileName()
219219
if ($response->headers->get('content-type')) {
220220
$this->assertSame('text/x-php', $response->headers->get('content-type'));
221221
}
222-
$this->assertContains(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition'));
223-
$this->assertContains($fileName, $response->headers->get('content-disposition'));
222+
$this->assertStringContainsString(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition'));
223+
$this->assertStringContainsString($fileName, $response->headers->get('content-disposition'));
224224
}
225225

226226
public function testFileWithOwnFileNameAsInline()
@@ -236,8 +236,8 @@ public function testFileWithOwnFileNameAsInline()
236236
if ($response->headers->get('content-type')) {
237237
$this->assertSame('text/x-php', $response->headers->get('content-type'));
238238
}
239-
$this->assertContains(ResponseHeaderBag::DISPOSITION_INLINE, $response->headers->get('content-disposition'));
240-
$this->assertContains($fileName, $response->headers->get('content-disposition'));
239+
$this->assertStringContainsString(ResponseHeaderBag::DISPOSITION_INLINE, $response->headers->get('content-disposition'));
240+
$this->assertStringContainsString($fileName, $response->headers->get('content-disposition'));
241241
}
242242

243243
public function testFileFromPath()
@@ -252,8 +252,8 @@ public function testFileFromPath()
252252
if ($response->headers->get('content-type')) {
253253
$this->assertSame('text/x-php', $response->headers->get('content-type'));
254254
}
255-
$this->assertContains(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition'));
256-
$this->assertContains(basename(__FILE__), $response->headers->get('content-disposition'));
255+
$this->assertStringContainsString(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition'));
256+
$this->assertStringContainsString(basename(__FILE__), $response->headers->get('content-disposition'));
257257
}
258258

259259
public function testFileFromPathWithCustomizedFileName()
@@ -268,8 +268,8 @@ public function testFileFromPathWithCustomizedFileName()
268268
if ($response->headers->get('content-type')) {
269269
$this->assertSame('text/x-php', $response->headers->get('content-type'));
270270
}
271-
$this->assertContains(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition'));
272-
$this->assertContains('test.php', $response->headers->get('content-disposition'));
271+
$this->assertStringContainsString(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition'));
272+
$this->assertStringContainsString('test.php', $response->headers->get('content-disposition'));
273273
}
274274

275275
public function testFileWhichDoesNotExist()

Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -824,9 +824,9 @@ public function testValidationMapping()
824824

825825
$this->assertSame('addYamlMappings', $calls[4][0]);
826826
$this->assertCount(3, $calls[4][1][0]);
827-
$this->assertContains('foo.yml', $calls[4][1][0][0]);
828-
$this->assertContains('validation.yml', $calls[4][1][0][1]);
829-
$this->assertContains('validation.yaml', $calls[4][1][0][2]);
827+
$this->assertStringContainsString('foo.yml', $calls[4][1][0][0]);
828+
$this->assertStringContainsString('validation.yml', $calls[4][1][0][1]);
829+
$this->assertStringContainsString('validation.yaml', $calls[4][1][0][2]);
830830
}
831831

832832
public function testFormsCanBeEnabledWithoutCsrfProtection()

Tests/Functional/CachePoolClearCommandTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public function testClearPrivatePool()
3131
$tester->execute(['pools' => ['cache.private_pool']], ['decorated' => false]);
3232

3333
$this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success');
34-
$this->assertContains('Clearing cache pool: cache.private_pool', $tester->getDisplay());
35-
$this->assertContains('[OK] Cache was successfully cleared.', $tester->getDisplay());
34+
$this->assertStringContainsString('Clearing cache pool: cache.private_pool', $tester->getDisplay());
35+
$this->assertStringContainsString('[OK] Cache was successfully cleared.', $tester->getDisplay());
3636
}
3737

3838
public function testClearPublicPool()
@@ -41,8 +41,8 @@ public function testClearPublicPool()
4141
$tester->execute(['pools' => ['cache.public_pool']], ['decorated' => false]);
4242

4343
$this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success');
44-
$this->assertContains('Clearing cache pool: cache.public_pool', $tester->getDisplay());
45-
$this->assertContains('[OK] Cache was successfully cleared.', $tester->getDisplay());
44+
$this->assertStringContainsString('Clearing cache pool: cache.public_pool', $tester->getDisplay());
45+
$this->assertStringContainsString('[OK] Cache was successfully cleared.', $tester->getDisplay());
4646
}
4747

4848
public function testClearPoolWithCustomClearer()
@@ -51,8 +51,8 @@ public function testClearPoolWithCustomClearer()
5151
$tester->execute(['pools' => ['cache.pool_with_clearer']], ['decorated' => false]);
5252

5353
$this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success');
54-
$this->assertContains('Clearing cache pool: cache.pool_with_clearer', $tester->getDisplay());
55-
$this->assertContains('[OK] Cache was successfully cleared.', $tester->getDisplay());
54+
$this->assertStringContainsString('Clearing cache pool: cache.pool_with_clearer', $tester->getDisplay());
55+
$this->assertStringContainsString('[OK] Cache was successfully cleared.', $tester->getDisplay());
5656
}
5757

5858
public function testCallClearer()
@@ -61,8 +61,8 @@ public function testCallClearer()
6161
$tester->execute(['pools' => ['cache.app_clearer']], ['decorated' => false]);
6262

6363
$this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success');
64-
$this->assertContains('Calling cache clearer: cache.app_clearer', $tester->getDisplay());
65-
$this->assertContains('[OK] Cache was successfully cleared.', $tester->getDisplay());
64+
$this->assertStringContainsString('Calling cache clearer: cache.app_clearer', $tester->getDisplay());
65+
$this->assertStringContainsString('[OK] Cache was successfully cleared.', $tester->getDisplay());
6666
}
6767

6868
public function testClearUnexistingPool()
@@ -86,7 +86,7 @@ public function testLegacyClearCommand()
8686

8787
$tester->execute(['pools' => []]);
8888

89-
$this->assertContains('Cache was successfully cleared', $tester->getDisplay());
89+
$this->assertStringContainsString('Cache was successfully cleared', $tester->getDisplay());
9090
}
9191

9292
private function createCommandTester()

Tests/Functional/ConfigDebugCommandTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function testDumpBundleName()
3636
$ret = $tester->execute(['name' => 'TestBundle']);
3737

3838
$this->assertSame(0, $ret, 'Returns 0 in case of success');
39-
$this->assertContains('custom: foo', $tester->getDisplay());
39+
$this->assertStringContainsString('custom: foo', $tester->getDisplay());
4040
}
4141

4242
public function testDumpBundleOption()
@@ -45,7 +45,7 @@ public function testDumpBundleOption()
4545
$ret = $tester->execute(['name' => 'TestBundle', 'path' => 'custom']);
4646

4747
$this->assertSame(0, $ret, 'Returns 0 in case of success');
48-
$this->assertContains('foo', $tester->getDisplay());
48+
$this->assertStringContainsString('foo', $tester->getDisplay());
4949
}
5050

5151
public function testParametersValuesAreResolved()
@@ -54,16 +54,16 @@ public function testParametersValuesAreResolved()
5454
$ret = $tester->execute(['name' => 'framework']);
5555

5656
$this->assertSame(0, $ret, 'Returns 0 in case of success');
57-
$this->assertContains("locale: '%env(LOCALE)%'", $tester->getDisplay());
58-
$this->assertContains('secret: test', $tester->getDisplay());
57+
$this->assertStringContainsString("locale: '%env(LOCALE)%'", $tester->getDisplay());
58+
$this->assertStringContainsString('secret: test', $tester->getDisplay());
5959
}
6060

6161
public function testDumpUndefinedBundleOption()
6262
{
6363
$tester = $this->createCommandTester();
6464
$tester->execute(['name' => 'TestBundle', 'path' => 'foo']);
6565

66-
$this->assertContains('Unable to find configuration for "test.foo"', $tester->getDisplay());
66+
$this->assertStringContainsString('Unable to find configuration for "test.foo"', $tester->getDisplay());
6767
}
6868

6969
/**

Tests/Functional/ConfigDumpReferenceCommandTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public function testDumpBundleName()
3636
$ret = $tester->execute(['name' => 'TestBundle']);
3737

3838
$this->assertSame(0, $ret, 'Returns 0 in case of success');
39-
$this->assertContains('test:', $tester->getDisplay());
40-
$this->assertContains(' custom:', $tester->getDisplay());
39+
$this->assertStringContainsString('test:', $tester->getDisplay());
40+
$this->assertStringContainsString(' custom:', $tester->getDisplay());
4141
}
4242

4343
public function testDumpAtPath()
@@ -70,7 +70,7 @@ public function testDumpAtPathXml()
7070
]);
7171

7272
$this->assertSame(1, $ret);
73-
$this->assertContains('[ERROR] The "path" option is only available for the "yaml" format.', $tester->getDisplay());
73+
$this->assertStringContainsString('[ERROR] The "path" option is only available for the "yaml" format.', $tester->getDisplay());
7474
}
7575

7676
/**

Tests/Functional/ContainerDebugCommandTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function testNoDebug()
4444
$tester = new ApplicationTester($application);
4545
$tester->run(['command' => 'debug:container']);
4646

47-
$this->assertContains('public', $tester->getDisplay());
47+
$this->assertStringContainsString('public', $tester->getDisplay());
4848
}
4949

5050
public function testPrivateAlias()
@@ -56,11 +56,11 @@ public function testPrivateAlias()
5656

5757
$tester = new ApplicationTester($application);
5858
$tester->run(['command' => 'debug:container', '--show-private' => true]);
59-
$this->assertContains('public', $tester->getDisplay());
60-
$this->assertContains('private_alias', $tester->getDisplay());
59+
$this->assertStringContainsString('public', $tester->getDisplay());
60+
$this->assertStringContainsString('private_alias', $tester->getDisplay());
6161

6262
$tester->run(['command' => 'debug:container']);
63-
$this->assertContains('public', $tester->getDisplay());
64-
$this->assertNotContains('private_alias', $tester->getDisplay());
63+
$this->assertStringContainsString('public', $tester->getDisplay());
64+
$this->assertStringNotContainsString('private_alias', $tester->getDisplay());
6565
}
6666
}

Tests/Functional/DebugAutowiringCommandTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public function testBasicFunctionality()
2929
$tester = new ApplicationTester($application);
3030
$tester->run(['command' => 'debug:autowiring']);
3131

32-
$this->assertContains('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay());
33-
$this->assertContains('alias to http_kernel', $tester->getDisplay());
32+
$this->assertStringContainsString('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay());
33+
$this->assertStringContainsString('alias to http_kernel', $tester->getDisplay());
3434
}
3535

3636
public function testSearchArgument()
@@ -43,8 +43,8 @@ public function testSearchArgument()
4343
$tester = new ApplicationTester($application);
4444
$tester->run(['command' => 'debug:autowiring', 'search' => 'kern']);
4545

46-
$this->assertContains('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay());
47-
$this->assertNotContains('Symfony\Component\Routing\RouterInterface', $tester->getDisplay());
46+
$this->assertStringContainsString('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay());
47+
$this->assertStringNotContainsString('Symfony\Component\Routing\RouterInterface', $tester->getDisplay());
4848
}
4949

5050
public function testSearchNoResults()
@@ -57,7 +57,7 @@ public function testSearchNoResults()
5757
$tester = new ApplicationTester($application);
5858
$tester->run(['command' => 'debug:autowiring', 'search' => 'foo_fake'], ['capture_stderr_separately' => true]);
5959

60-
$this->assertContains('No autowirable classes or interfaces found matching "foo_fake"', $tester->getErrorOutput());
60+
$this->assertStringContainsString('No autowirable classes or interfaces found matching "foo_fake"', $tester->getErrorOutput());
6161
$this->assertEquals(1, $tester->getStatusCode());
6262
}
6363
}

0 commit comments

Comments
 (0)