Skip to content

Commit

Permalink
Remove deprecated assertContains
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioBlazek committed Aug 6, 2019
1 parent 36466a3 commit 622c638
Show file tree
Hide file tree
Showing 54 changed files with 148 additions and 148 deletions.
Expand Up @@ -208,7 +208,7 @@ public function testLoadBasicCacheDriver(string $class, array $config, array $ex
$this->assertEquals("%$class%", $definition->getClass());

foreach (array_unique($expectedCalls) as $call) {
$this->assertContains($call, $actualCalls);
$this->assertStringContainsString($call, $actualCalls);
}
}

Expand Down
Expand Up @@ -789,7 +789,7 @@ public function testChoicesForValuesOptimization()
$unitOfWorkIdentityMap = $this->em->getUnitOfWork()->getIdentityMap();
$managedEntitiesNames = array_map('strval', $unitOfWorkIdentityMap['Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity']);

$this->assertContains((string) $entity1, $managedEntitiesNames);
$this->assertStringContainsString((string) $entity1, $managedEntitiesNames);
$this->assertNotContains((string) $entity2, $managedEntitiesNames);
}

Expand Down
Expand Up @@ -46,8 +46,8 @@ public function testLegacyTestMethodIsDetectedAsSuch()
public function testItCanBeConvertedToAString()
{
$deprecation = new Deprecation('💩', $this->debugBacktrace(), __FILE__);
$this->assertContains('💩', $deprecation->toString());
$this->assertContains(__FUNCTION__, $deprecation->toString());
$this->assertStringContainsString('💩', $deprecation->toString());
$this->assertStringContainsString(__FUNCTION__, $deprecation->toString());
}

public function testItRulesOutFilesOutsideVendorsAsIndirect()
Expand Down
Expand Up @@ -50,11 +50,11 @@ function ($template) { return $template->getLogicalName(); },
);

$this->assertCount(7, $templates, '->findAllTemplates() find all templates in the bundles and global folders');
$this->assertContains('BaseBundle::base.format.engine', $templates);
$this->assertContains('BaseBundle::this.is.a.template.format.engine', $templates);
$this->assertContains('BaseBundle:controller:base.format.engine', $templates);
$this->assertContains('BaseBundle:controller:custom.format.engine', $templates);
$this->assertContains('::this.is.a.template.format.engine', $templates);
$this->assertContains('::resource.format.engine', $templates);
$this->assertStringContainsString('BaseBundle::base.format.engine', $templates);
$this->assertStringContainsString('BaseBundle::this.is.a.template.format.engine', $templates);
$this->assertStringContainsString('BaseBundle:controller:base.format.engine', $templates);
$this->assertStringContainsString('BaseBundle:controller:custom.format.engine', $templates);
$this->assertStringContainsString('::this.is.a.template.format.engine', $templates);
$this->assertStringContainsString('::resource.format.engine', $templates);
}
}
Expand Up @@ -45,7 +45,7 @@ public function testCommandWithValidKey()
$tester = $this->getCommandTester($this->getKernel());
$tester->execute(['pool' => 'foo', 'key' => 'bar']);

$this->assertContains('[OK] Cache item "bar" was successfully deleted.', $tester->getDisplay());
$this->assertStringContainsString('[OK] Cache item "bar" was successfully deleted.', $tester->getDisplay());
}

public function testCommandWithInValidKey()
Expand All @@ -62,7 +62,7 @@ public function testCommandWithInValidKey()
$tester = $this->getCommandTester($this->getKernel());
$tester->execute(['pool' => 'foo', 'key' => 'bar']);

$this->assertContains('[NOTE] Cache item "bar" does not exist in cache pool "foo".', $tester->getDisplay());
$this->assertStringContainsString('[NOTE] Cache item "bar" does not exist in cache pool "foo".', $tester->getDisplay());
}

public function testCommandDeleteFailed()
Expand Down
Expand Up @@ -69,7 +69,7 @@ public function testLintFilesFromBundleDirectory()
);

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

/**
Expand Down
Expand Up @@ -226,7 +226,7 @@ public function testRunOnlyWarnsOnUnregistrableCommandAtTheEnd()
$this->assertSame(0, $tester->getStatusCode());
$display = explode('Lists commands', $tester->getDisplay());

$this->assertContains(trim('[WARNING] Some commands could not be registered:'), trim($display[1]));
$this->assertStringContainsString(trim('[WARNING] Some commands could not be registered:'), trim($display[1]));
}

public function testSuggestingPackagesWithExactMatch()
Expand Down
Expand Up @@ -546,8 +546,8 @@ public function testAddLink()
$controller->addLink($request, $link2);

$links = $request->attributes->get('_links')->getLinks();
$this->assertContains($link1, $links);
$this->assertContains($link2, $links);
$this->assertStringContainsString($link1, $links);
$this->assertStringContainsString($link2, $links);
}
}

Expand Down
Expand Up @@ -783,29 +783,29 @@ public function testTranslator()

$files = array_map('realpath', $options['resource_files']['en']);
$ref = new \ReflectionClass('Symfony\Component\Validator\Validation');
$this->assertContains(
$this->assertStringContainsString(
strtr(\dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', \DIRECTORY_SEPARATOR),
$files,
'->registerTranslatorConfiguration() finds Validator translation resources'
);
$ref = new \ReflectionClass('Symfony\Component\Form\Form');
$this->assertContains(
$this->assertStringContainsString(
strtr(\dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', \DIRECTORY_SEPARATOR),
$files,
'->registerTranslatorConfiguration() finds Form translation resources'
);
$ref = new \ReflectionClass('Symfony\Component\Security\Core\Security');
$this->assertContains(
$this->assertStringContainsString(
strtr(\dirname($ref->getFileName()).'/Resources/translations/security.en.xlf', '/', \DIRECTORY_SEPARATOR),
$files,
'->registerTranslatorConfiguration() finds Security translation resources'
);
$this->assertContains(
$this->assertStringContainsString(
strtr(__DIR__.'/Fixtures/translations/test_paths.en.yml', '/', \DIRECTORY_SEPARATOR),
$files,
'->registerTranslatorConfiguration() finds translation resources in custom paths'
);
$this->assertContains(
$this->assertStringContainsString(
strtr(__DIR__.'/translations/test_default.en.xlf', '/', \DIRECTORY_SEPARATOR),
$files,
'->registerTranslatorConfiguration() finds translation resources in default path'
Expand Down Expand Up @@ -835,7 +835,7 @@ public function testLegacyTranslationsDirectory()
$files = array_map('realpath', $options['resource_files']['en']);

$dir = str_replace('/', \DIRECTORY_SEPARATOR, __DIR__.'/Fixtures/Resources/translations/test_default.en.xlf');
$this->assertContains($dir, $files, '->registerTranslatorConfiguration() finds translation resources in legacy directory');
$this->assertStringContainsString($dir, $files, '->registerTranslatorConfiguration() finds translation resources in legacy directory');
}

public function testTranslatorMultipleFallbacks()
Expand Down
Expand Up @@ -31,8 +31,8 @@ public function testListPools()
$tester->execute([]);

$this->assertSame(0, $tester->getStatusCode(), 'cache:pool:list exits with 0 in case of success');
$this->assertContains('cache.app', $tester->getDisplay());
$this->assertContains('cache.system', $tester->getDisplay());
$this->assertStringContainsString('cache.app', $tester->getDisplay());
$this->assertStringContainsString('cache.system', $tester->getDisplay());
}

public function testEmptyList()
Expand Down
Expand Up @@ -71,7 +71,7 @@ public function testDumpWithPrefixedEnv()
$tester = $this->createCommandTester();
$tester->execute(['name' => 'FrameworkBundle']);

$this->assertContains("cookie_httponly: '%env(bool:COOKIE_HTTPONLY)%'", $tester->getDisplay());
$this->assertStringContainsString("cookie_httponly: '%env(bool:COOKIE_HTTPONLY)%'", $tester->getDisplay());
}

/**
Expand Down
Expand Up @@ -61,8 +61,8 @@ public function testPrivateAlias()
$this->assertNotContains('private_alias', $tester->getDisplay());

$tester->run(['command' => 'debug:container']);
$this->assertContains('public', $tester->getDisplay());
$this->assertContains('private_alias', $tester->getDisplay());
$this->assertStringContainsString('public', $tester->getDisplay());
$this->assertStringContainsString('private_alias', $tester->getDisplay());
}

/**
Expand Down Expand Up @@ -130,7 +130,7 @@ public function testDescribeEnvVar()
$tester = new ApplicationTester($application);
$tester->run(['command' => 'debug:container', '--env-var' => 'js'], ['decorated' => false]);

$this->assertContains(file_get_contents(__DIR__.'/Fixtures/describe_env_vars.txt'), $tester->getDisplay(true));
$this->assertStringContainsString(file_get_contents(__DIR__.'/Fixtures/describe_env_vars.txt'), $tester->getDisplay(true));
}

public function provideIgnoreBackslashWhenFindingService()
Expand Down
Expand Up @@ -56,7 +56,7 @@ public function testSearchIgnoreBackslashWhenFindingService()

$tester = new ApplicationTester($application);
$tester->run(['command' => 'debug:autowiring', 'search' => 'HttpKernelHttpKernelInterface']);
$this->assertContains('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay());
$this->assertStringContainsString('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay());
}

public function testSearchNoResults()
Expand All @@ -83,7 +83,7 @@ public function testSearchNotAliasedService()
$tester = new ApplicationTester($application);
$tester->run(['command' => 'debug:autowiring', 'search' => 'redirect']);

$this->assertContains(' more concrete service would be displayed when adding the "--all" option.', $tester->getDisplay());
$this->assertStringContainsString(' more concrete service would be displayed when adding the "--all" option.', $tester->getDisplay());
}

public function testSearchNotAliasedServiceWithAll()
Expand All @@ -95,6 +95,6 @@ public function testSearchNotAliasedServiceWithAll()

$tester = new ApplicationTester($application);
$tester->run(['command' => 'debug:autowiring', 'search' => 'redirect', '--all' => true]);
$this->assertContains('Pro-tip: use interfaces in your type-hints instead of classes to benefit from the dependency inversion principle.', $tester->getDisplay());
$this->assertStringContainsString('Pro-tip: use interfaces in your type-hints instead of classes to benefit from the dependency inversion principle.', $tester->getDisplay());
}
}
Expand Up @@ -34,9 +34,9 @@ public function testDumpAllRoutes()
$display = $tester->getDisplay();

$this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains('routerdebug_test', $display);
$this->assertContains('/test', $display);
$this->assertContains('/session', $display);
$this->assertStringContainsString('routerdebug_test', $display);
$this->assertStringContainsString('/test', $display);
$this->assertStringContainsString('/session', $display);
}

public function testDumpOneRoute()
Expand All @@ -45,8 +45,8 @@ public function testDumpOneRoute()
$ret = $tester->execute(['name' => 'routerdebug_session_welcome']);

$this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains('routerdebug_session_welcome', $tester->getDisplay());
$this->assertContains('/session', $tester->getDisplay());
$this->assertStringContainsString('routerdebug_session_welcome', $tester->getDisplay());
$this->assertStringContainsString('/session', $tester->getDisplay());
}

public function testSearchMultipleRoutes()
Expand All @@ -56,9 +56,9 @@ public function testSearchMultipleRoutes()
$ret = $tester->execute(['name' => 'routerdebug'], ['interactive' => true]);

$this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains('Select one of the matching routes:', $tester->getDisplay());
$this->assertContains('routerdebug_test', $tester->getDisplay());
$this->assertContains('/test', $tester->getDisplay());
$this->assertStringContainsString('Select one of the matching routes:', $tester->getDisplay());
$this->assertStringContainsString('routerdebug_test', $tester->getDisplay());
$this->assertStringContainsString('/test', $tester->getDisplay());
}

public function testSearchWithThrow()
Expand Down
Expand Up @@ -33,13 +33,13 @@ public function testDumpAllTrans()
$ret = $tester->execute(['locale' => 'en']);

$this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains('missing messages hello_from_construct_arg_service', $tester->getDisplay());
$this->assertContains('missing messages hello_from_subscriber_service', $tester->getDisplay());
$this->assertContains('missing messages hello_from_property_service', $tester->getDisplay());
$this->assertContains('missing messages hello_from_method_calls_service', $tester->getDisplay());
$this->assertContains('missing messages hello_from_controller', $tester->getDisplay());
$this->assertContains('unused validators This value should be blank.', $tester->getDisplay());
$this->assertContains('unused security Invalid CSRF token.', $tester->getDisplay());
$this->assertStringContainsString('missing messages hello_from_construct_arg_service', $tester->getDisplay());
$this->assertStringContainsString('missing messages hello_from_subscriber_service', $tester->getDisplay());
$this->assertStringContainsString('missing messages hello_from_property_service', $tester->getDisplay());
$this->assertStringContainsString('missing messages hello_from_method_calls_service', $tester->getDisplay());
$this->assertStringContainsString('missing messages hello_from_controller', $tester->getDisplay());
$this->assertStringContainsString('unused validators This value should be blank.', $tester->getDisplay());
$this->assertStringContainsString('unused security Invalid CSRF token.', $tester->getDisplay());
}

private function createCommandTester(): CommandTester
Expand Down
Expand Up @@ -109,7 +109,7 @@ public function testEncodePasswordNative()
], ['interactive' => false]);

$output = $this->passwordEncoderCommandTester->getDisplay();
$this->assertContains('Password encoding succeeded', $output);
$this->assertStringContainsString('Password encoding succeeded', $output);

$encoder = new NativePasswordEncoder();
preg_match('# Encoded password\s{1,}([\w+\/$.,=]+={0,2})\s+#', $output, $matches);
Expand All @@ -130,7 +130,7 @@ public function testEncodePasswordSodium()
], ['interactive' => false]);

$output = $this->passwordEncoderCommandTester->getDisplay();
$this->assertContains('Password encoding succeeded', $output);
$this->assertStringContainsString('Password encoding succeeded', $output);

preg_match('# Encoded password\s+(\$?\$[\w,=\$+\/]+={0,2})\s+#', $output, $matches);
$hash = $matches[1];
Expand Down
Expand Up @@ -36,7 +36,7 @@ public function testLoadEmptyConfiguration()

$this->assertEquals('Twig\Environment', $container->getDefinition('twig')->getClass(), '->load() loads the twig.xml file');

$this->assertContains('form_div_layout.html.twig', $container->getParameter('twig.form.resources'), '->load() includes default template for form resources');
$this->assertStringContainsString('form_div_layout.html.twig', $container->getParameter('twig.form.resources'), '->load() includes default template for form resources');

// Twig options
$options = $container->getDefinition('twig')->getArgument(1);
Expand All @@ -59,8 +59,8 @@ public function testLoadFullConfiguration($format)

// Form resources
$resources = $container->getParameter('twig.form.resources');
$this->assertContains('form_div_layout.html.twig', $resources, '->load() includes default template for form resources');
$this->assertContains('MyBundle::form.html.twig', $resources, '->load() merges new templates into form resources');
$this->assertStringContainsString('form_div_layout.html.twig', $resources, '->load() includes default template for form resources');
$this->assertStringContainsString('MyBundle::form.html.twig', $resources, '->load() merges new templates into form resources');

// Globals
$calls = $container->getDefinition('twig')->getMethodCalls();
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php
Expand Up @@ -159,9 +159,9 @@ public function testMultiPartRequest()
->expects($this->once())
->method('request')
->with('POST', 'http://example.com/', $this->callback(function ($options) {
$this->assertContains('Content-Type: multipart/form-data', implode('', $options['headers']));
$this->assertStringContainsString('Content-Type: multipart/form-data', implode('', $options['headers']));
$this->assertInstanceOf('\Generator', $options['body']);
$this->assertContains('my_file', implode('', iterator_to_array($options['body'])));
$this->assertStringContainsString('my_file', implode('', iterator_to_array($options['body'])));

return true;
}))
Expand Down
Expand Up @@ -66,7 +66,7 @@ public function testGetItems()
$itemKey = $item->getKey();

$this->assertEquals($itemKey, $key, 'Keys must be preserved when fetching multiple items');
$this->assertContains($key, $keys, 'Cache key can not change.');
$this->assertStringContainsString($key, $keys, 'Cache key can not change.');
$this->assertFalse($item->isHit());

// Remove $key for $keys
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Tests/Simple/NullCacheTest.php
Expand Up @@ -48,7 +48,7 @@ public function testGetMultiple()
$count = 0;

foreach ($items as $key => $item) {
$this->assertContains($key, $keys, 'Cache key can not change.');
$this->assertStringContainsString($key, $keys, 'Cache key can not change.');
$this->assertSame($default, $item);

// Remove $key for $keys
Expand Down
Expand Up @@ -32,7 +32,7 @@ public function testAppendingSomeNode()
->append($child);

$this->assertCount(3, $this->getField($parent, 'children'));
$this->assertContains($child, $this->getField($parent, 'children'));
$this->assertStringContainsString($child, $this->getField($parent, 'children'));
}

/**
Expand Down

0 comments on commit 622c638

Please sign in to comment.