Merge branch '2.8' into 3.2
* 2.8: Fixes a typo in the form collector styles [HttpKernel] Fixed bug with purging of HTTPS URLs fix some risky tests [DI] [YamlFileLoader] change error message of a non existing file [Security] Added option to return true in the method isRememberMeRequested
This commit is contained in:
commit
8cd835e658
@ -25,5 +25,7 @@ class DbalSessionHandlerTest extends TestCase
|
||||
{
|
||||
$connection = $this->getMockBuilder('Doctrine\DBAL\Connection')->disableOriginalConstructor()->getMock();
|
||||
$handler = new DbalSessionHandler($connection);
|
||||
|
||||
$this->assertInstanceOf('Symfony\Bridge\Doctrine\HttpFoundation\DbalSessionHandler', $handler);
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,10 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
||||
;
|
||||
|
||||
$this->renderer->setTheme($view, array('page_dynamic_extends.html.twig'));
|
||||
$this->renderer->searchAndRenderBlock($view, 'row');
|
||||
$this->assertMatchesXpath(
|
||||
$this->renderer->searchAndRenderBlock($view, 'row'),
|
||||
'/div/label[text()="child"]'
|
||||
);
|
||||
}
|
||||
|
||||
public function isSelectedChoiceProvider()
|
||||
|
@ -30,11 +30,10 @@ class StopwatchHelperTest extends TestCase
|
||||
public function testProdEnvironment()
|
||||
{
|
||||
$helper = new StopwatchHelper(null);
|
||||
$helper->start('foo');
|
||||
|
||||
try {
|
||||
$helper->start('foo');
|
||||
} catch (\BadMethodCallException $e) {
|
||||
$this->fail('Assumed stopwatch is not called when not provided');
|
||||
}
|
||||
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
||||
// can be executed without throwing any exceptions
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
}
|
||||
|
@ -19,21 +19,9 @@ class TemplateTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getTemplateToPathProvider
|
||||
*/
|
||||
public function testGetPathForTemplatesInABundle($template, $path)
|
||||
public function testGetPathForTemplate($template, $path)
|
||||
{
|
||||
if ($template->get('bundle')) {
|
||||
$this->assertEquals($template->getPath(), $path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTemplateToPathProvider
|
||||
*/
|
||||
public function testGetPathForTemplatesOutOfABundle($template, $path)
|
||||
{
|
||||
if (!$template->get('bundle')) {
|
||||
$this->assertEquals($template->getPath(), $path);
|
||||
}
|
||||
$this->assertSame($template->getPath(), $path);
|
||||
}
|
||||
|
||||
public function getTemplateToPathProvider()
|
||||
|
@ -60,7 +60,7 @@
|
||||
}
|
||||
#tree-menu .empty {
|
||||
border: 0;
|
||||
mmargin: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
#tree-details-container {
|
||||
|
@ -699,8 +699,12 @@ class ApplicationTest extends TestCase
|
||||
$input = new ArgvInput(array('cli.php', '-v', 'foo:bar'));
|
||||
$application->run($input, $output);
|
||||
|
||||
$this->addToAssertionCount(1);
|
||||
|
||||
$input = new ArgvInput(array('cli.php', '--verbose', 'foo:bar'));
|
||||
$application->run($input, $output);
|
||||
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function testRunReturnsIntegerExitCode()
|
||||
|
@ -34,7 +34,7 @@ class TableTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider testRenderProvider
|
||||
* @dataProvider renderProvider
|
||||
*/
|
||||
public function testRender($headers, $rows, $style, $expected, $decorated = false)
|
||||
{
|
||||
@ -50,7 +50,7 @@ class TableTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider testRenderProvider
|
||||
* @dataProvider renderProvider
|
||||
*/
|
||||
public function testRenderAddRows($headers, $rows, $style, $expected, $decorated = false)
|
||||
{
|
||||
@ -66,7 +66,7 @@ class TableTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider testRenderProvider
|
||||
* @dataProvider renderProvider
|
||||
*/
|
||||
public function testRenderAddRowsOneByOne($headers, $rows, $style, $expected, $decorated = false)
|
||||
{
|
||||
@ -83,7 +83,7 @@ class TableTest extends TestCase
|
||||
$this->assertEquals($expected, $this->getOutputContent($output));
|
||||
}
|
||||
|
||||
public function testRenderProvider()
|
||||
public function renderProvider()
|
||||
{
|
||||
$books = array(
|
||||
array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'),
|
||||
|
@ -385,7 +385,7 @@ class YamlFileLoader extends FileLoader
|
||||
}
|
||||
|
||||
if (!file_exists($file)) {
|
||||
throw new InvalidArgumentException(sprintf('The service file "%s" is not valid.', $file));
|
||||
throw new InvalidArgumentException(sprintf('The file "%s" does not exist.', $file));
|
||||
}
|
||||
|
||||
if (null === $this->yamlParser) {
|
||||
|
@ -114,6 +114,8 @@ class CheckCircularReferencesPassTest extends TestCase
|
||||
$container->register('b')->addMethodCall('setA', array(new Reference('a')));
|
||||
|
||||
$this->process($container);
|
||||
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
protected function process(ContainerBuilder $container)
|
||||
|
@ -48,6 +48,8 @@ class CheckDefinitionValidityPassTest extends TestCase
|
||||
$container->register('d', 'class')->setSynthetic(true);
|
||||
|
||||
$this->process($container);
|
||||
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function testValidTags()
|
||||
@ -59,6 +61,8 @@ class CheckDefinitionValidityPassTest extends TestCase
|
||||
$container->register('d', 'class')->addTag('foo', array('bar' => 1.1));
|
||||
|
||||
$this->process($container);
|
||||
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,6 +28,10 @@ class CheckExceptionOnInvalidReferenceBehaviorPassTest extends TestCase
|
||||
->addArgument(new Reference('b'))
|
||||
;
|
||||
$container->register('b', '\stdClass');
|
||||
|
||||
$this->process($container);
|
||||
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,6 +38,8 @@ class CheckReferenceValidityPassTest extends TestCase
|
||||
$container->register('b');
|
||||
|
||||
$this->process($container);
|
||||
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
protected function process(ContainerBuilder $container)
|
||||
|
@ -351,6 +351,8 @@ class PhpDumperTest extends TestCase
|
||||
|
||||
$dumper = new PhpDumper($container);
|
||||
$dumper->dump();
|
||||
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function testCircularReferenceAllowanceForInlinedDefinitionsForLazyServices()
|
||||
@ -388,6 +390,8 @@ class PhpDumperTest extends TestCase
|
||||
|
||||
$dumper->setProxyDumper(new DummyProxyDumper());
|
||||
$dumper->dump();
|
||||
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function testDumpContainerBuilderWithFrozenConstructorIncludingPrivateServices()
|
||||
|
@ -141,6 +141,8 @@ class XmlDumperTest extends TestCase
|
||||
$container->compile();
|
||||
$dumper = new XmlDumper($container);
|
||||
$dumper->dump();
|
||||
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function provideCompiledContainerData()
|
||||
|
@ -33,40 +33,33 @@ class YamlFileLoaderTest extends TestCase
|
||||
require_once self::$fixturesPath.'/includes/ProjectExtension.php';
|
||||
}
|
||||
|
||||
public function testLoadFile()
|
||||
/**
|
||||
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
|
||||
* @expectedExceptionMessageRegExp /The file ".+" does not exist./
|
||||
*/
|
||||
public function testLoadUnExistFile()
|
||||
{
|
||||
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/ini'));
|
||||
$r = new \ReflectionObject($loader);
|
||||
$m = $r->getMethod('loadFile');
|
||||
$m->setAccessible(true);
|
||||
|
||||
try {
|
||||
$m->invoke($loader, 'foo.yml');
|
||||
$this->fail('->load() throws an InvalidArgumentException if the loaded file does not exist');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the loaded file does not exist');
|
||||
$this->assertEquals('The service file "foo.yml" is not valid.', $e->getMessage(), '->load() throws an InvalidArgumentException if the loaded file does not exist');
|
||||
}
|
||||
$m->invoke($loader, 'foo.yml');
|
||||
}
|
||||
|
||||
try {
|
||||
$m->invoke($loader, 'parameters.ini');
|
||||
$this->fail('->load() throws an InvalidArgumentException if the loaded file is not a valid YAML file');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the loaded file is not a valid YAML file');
|
||||
$this->assertEquals('The service file "parameters.ini" is not valid.', $e->getMessage(), '->load() throws an InvalidArgumentException if the loaded file is not a valid YAML file');
|
||||
}
|
||||
/**
|
||||
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
|
||||
* @expectedExceptionMessageRegExp /The file ".+" does not contain valid YAML./
|
||||
*/
|
||||
public function testLoadInvalidYamlFile()
|
||||
{
|
||||
$path = self::$fixturesPath.'/ini';
|
||||
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator($path));
|
||||
$r = new \ReflectionObject($loader);
|
||||
$m = $r->getMethod('loadFile');
|
||||
$m->setAccessible(true);
|
||||
|
||||
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
|
||||
|
||||
foreach (array('nonvalid1', 'nonvalid2') as $fixture) {
|
||||
try {
|
||||
$m->invoke($loader, $fixture.'.yml');
|
||||
$this->fail('->load() throws an InvalidArgumentException if the loaded file does not validate');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the loaded file does not validate');
|
||||
$this->assertStringMatchesFormat('The service file "nonvalid%d.yml" is not valid.', $e->getMessage(), '->load() throws an InvalidArgumentException if the loaded file does not validate');
|
||||
}
|
||||
}
|
||||
$m->invoke($loader, $path.'/parameters.ini');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,6 +83,8 @@ class YamlFileLoaderTest extends TestCase
|
||||
array('bad_service'),
|
||||
array('bad_calls'),
|
||||
array('bad_format'),
|
||||
array('nonvalid1'),
|
||||
array('nonvalid2'),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -174,14 +174,20 @@ class TraceableEventDispatcherTest extends TestCase
|
||||
{
|
||||
$dispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch());
|
||||
$loop = 1;
|
||||
$dispatchedEvents = 0;
|
||||
$dispatcher->addListener('foo', $listener1 = function () use ($dispatcher, &$loop) {
|
||||
++$loop;
|
||||
if (2 == $loop) {
|
||||
$dispatcher->dispatch('foo');
|
||||
}
|
||||
});
|
||||
$dispatcher->addListener('foo', function () use (&$dispatchedEvents) {
|
||||
++$dispatchedEvents;
|
||||
});
|
||||
|
||||
$dispatcher->dispatch('foo');
|
||||
|
||||
$this->assertSame(2, $dispatchedEvents);
|
||||
}
|
||||
|
||||
public function testDispatchReusedEventNested()
|
||||
|
@ -442,14 +442,22 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$this->assertFilePermissions(400, $file);
|
||||
}
|
||||
|
||||
public function testChmodWrongMod()
|
||||
public function testChmodWithWrongModLeavesPreviousPermissionsUntouched()
|
||||
{
|
||||
$this->markAsSkippedIfChmodIsMissing();
|
||||
|
||||
if (defined('HHVM_VERSION')) {
|
||||
$this->markTestSkipped('chmod() changes permissions even when passing invalid modes on HHVM');
|
||||
}
|
||||
|
||||
$dir = $this->workspace.DIRECTORY_SEPARATOR.'file';
|
||||
touch($dir);
|
||||
|
||||
$permissions = fileperms($dir);
|
||||
|
||||
$this->filesystem->chmod($dir, 'Wrongmode');
|
||||
|
||||
$this->assertSame($permissions, fileperms($dir));
|
||||
}
|
||||
|
||||
public function testChmodRecursive()
|
||||
@ -536,7 +544,10 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$dir = $this->workspace.DIRECTORY_SEPARATOR.'dir';
|
||||
mkdir($dir);
|
||||
|
||||
$this->filesystem->chown($dir, $this->getFileOwner($dir));
|
||||
$owner = $this->getFileOwner($dir);
|
||||
$this->filesystem->chown($dir, $owner);
|
||||
|
||||
$this->assertSame($owner, $this->getFileOwner($dir));
|
||||
}
|
||||
|
||||
public function testChownRecursive()
|
||||
@ -548,7 +559,10 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$file = $dir.DIRECTORY_SEPARATOR.'file';
|
||||
touch($file);
|
||||
|
||||
$this->filesystem->chown($dir, $this->getFileOwner($dir), true);
|
||||
$owner = $this->getFileOwner($dir);
|
||||
$this->filesystem->chown($dir, $owner, true);
|
||||
|
||||
$this->assertSame($owner, $this->getFileOwner($file));
|
||||
}
|
||||
|
||||
public function testChownSymlink()
|
||||
@ -562,7 +576,10 @@ class FilesystemTest extends FilesystemTestCase
|
||||
|
||||
$this->filesystem->symlink($file, $link);
|
||||
|
||||
$this->filesystem->chown($link, $this->getFileOwner($link));
|
||||
$owner = $this->getFileOwner($link);
|
||||
$this->filesystem->chown($link, $owner);
|
||||
|
||||
$this->assertSame($owner, $this->getFileOwner($link));
|
||||
}
|
||||
|
||||
public function testChownLink()
|
||||
@ -633,7 +650,10 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$dir = $this->workspace.DIRECTORY_SEPARATOR.'dir';
|
||||
mkdir($dir);
|
||||
|
||||
$this->filesystem->chgrp($dir, $this->getFileGroup($dir));
|
||||
$group = $this->getFileGroup($dir);
|
||||
$this->filesystem->chgrp($dir, $group);
|
||||
|
||||
$this->assertSame($group, $this->getFileGroup($dir));
|
||||
}
|
||||
|
||||
public function testChgrpRecursive()
|
||||
@ -645,7 +665,10 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$file = $dir.DIRECTORY_SEPARATOR.'file';
|
||||
touch($file);
|
||||
|
||||
$this->filesystem->chgrp($dir, $this->getFileGroup($dir), true);
|
||||
$group = $this->getFileGroup($dir);
|
||||
$this->filesystem->chgrp($dir, $group, true);
|
||||
|
||||
$this->assertSame($group, $this->getFileGroup($file));
|
||||
}
|
||||
|
||||
public function testChgrpSymlink()
|
||||
@ -659,7 +682,10 @@ class FilesystemTest extends FilesystemTestCase
|
||||
|
||||
$this->filesystem->symlink($file, $link);
|
||||
|
||||
$this->filesystem->chgrp($link, $this->getFileGroup($link));
|
||||
$group = $this->getFileGroup($link);
|
||||
$this->filesystem->chgrp($link, $group);
|
||||
|
||||
$this->assertSame($group, $this->getFileGroup($link));
|
||||
}
|
||||
|
||||
public function testChgrpLink()
|
||||
|
@ -83,6 +83,8 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
// strip away <root> and </root>
|
||||
substr($dom->saveHTML(), 6, -8)
|
||||
));
|
||||
} else {
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,8 @@ class TranslationFilesTest extends TestCase
|
||||
} else {
|
||||
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);
|
||||
}
|
||||
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function provideTranslationFiles()
|
||||
|
@ -325,10 +325,13 @@ class Store implements StoreInterface
|
||||
*/
|
||||
public function purge($url)
|
||||
{
|
||||
$http = preg_replace('#^https#', 'http', $url);
|
||||
$https = preg_replace('#^http#', 'https', $url);
|
||||
$http = preg_replace('#^https:#', 'http:', $url);
|
||||
$https = preg_replace('#^http:#', 'https:', $url);
|
||||
|
||||
return $this->doPurge($http) || $this->doPurge($https);
|
||||
$purgedHttp = $this->doPurge($http);
|
||||
$purgedHttps = $this->doPurge($https);
|
||||
|
||||
return $purgedHttp || $purgedHttps;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,6 +25,18 @@ use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
|
||||
class InlineFragmentRendererTest extends TestCase
|
||||
{
|
||||
private $originalTrustedHeaderName;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->originalTrustedHeaderName = Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, $this->originalTrustedHeaderName);
|
||||
}
|
||||
|
||||
public function testRender()
|
||||
{
|
||||
$strategy = new InlineFragmentRenderer($this->getKernel($this->returnValue(new Response('foo'))));
|
||||
@ -50,7 +62,7 @@ class InlineFragmentRendererTest extends TestCase
|
||||
|
||||
$strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($subRequest));
|
||||
|
||||
$strategy->render(new ControllerReference('main_controller', array('object' => $object), array()), Request::create('/'));
|
||||
$this->assertSame('foo', $strategy->render(new ControllerReference('main_controller', array('object' => $object), array()), Request::create('/'))->getContent());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,14 +109,10 @@ class InlineFragmentRendererTest extends TestCase
|
||||
|
||||
public function testRenderWithTrustedHeaderDisabled()
|
||||
{
|
||||
$trustedHeaderName = Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP);
|
||||
|
||||
Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, '');
|
||||
|
||||
$strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest(Request::create('/')));
|
||||
$strategy->render('/', Request::create('/'));
|
||||
|
||||
Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, $trustedHeaderName);
|
||||
$this->assertSame('foo', $strategy->render('/', Request::create('/'))->getContent());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -152,22 +160,6 @@ class InlineFragmentRendererTest extends TestCase
|
||||
return $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Kernel expecting a request equals to $request
|
||||
* Allows delta in comparison in case REQUEST_TIME changed by 1 second.
|
||||
*/
|
||||
private function getKernelExpectingRequest(Request $request)
|
||||
{
|
||||
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('handle')
|
||||
->with($this->equalTo($request, 1))
|
||||
;
|
||||
|
||||
return $kernel;
|
||||
}
|
||||
|
||||
public function testExceptionInSubRequestsDoesNotMangleOutputBuffers()
|
||||
{
|
||||
$controllerResolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock();
|
||||
@ -240,6 +232,22 @@ class InlineFragmentRendererTest extends TestCase
|
||||
$request = Request::create('/', 'GET', array(), array(), array(), array('HTTP_IF_MODIFIED_SINCE' => 'Fri, 01 Jan 2016 00:00:00 GMT', 'HTTP_IF_NONE_MATCH' => '*'));
|
||||
$strategy->render('/', $request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Kernel expecting a request equals to $request
|
||||
* Allows delta in comparison in case REQUEST_TIME changed by 1 second.
|
||||
*/
|
||||
private function getKernelExpectingRequest(Request $request, $strict = false)
|
||||
{
|
||||
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
|
||||
$kernel
|
||||
->expects($this->once())
|
||||
->method('handle')
|
||||
->with($this->equalTo($request, 1))
|
||||
->willReturn(new Response('foo'));
|
||||
|
||||
return $kernel;
|
||||
}
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
@ -236,6 +236,33 @@ class StoreTest extends TestCase
|
||||
$this->assertFalse($this->store->isLocked($req));
|
||||
}
|
||||
|
||||
public function testPurgeHttps()
|
||||
{
|
||||
$request = Request::create('https://example.com/foo');
|
||||
$this->store->write($request, new Response('foo'));
|
||||
|
||||
$this->assertNotEmpty($this->getStoreMetadata($request));
|
||||
|
||||
$this->assertTrue($this->store->purge('https://example.com/foo'));
|
||||
$this->assertEmpty($this->getStoreMetadata($request));
|
||||
}
|
||||
|
||||
public function testPurgeHttpAndHttps()
|
||||
{
|
||||
$requestHttp = Request::create('https://example.com/foo');
|
||||
$this->store->write($requestHttp, new Response('foo'));
|
||||
|
||||
$requestHttps = Request::create('http://example.com/foo');
|
||||
$this->store->write($requestHttps, new Response('foo'));
|
||||
|
||||
$this->assertNotEmpty($this->getStoreMetadata($requestHttp));
|
||||
$this->assertNotEmpty($this->getStoreMetadata($requestHttps));
|
||||
|
||||
$this->assertTrue($this->store->purge('http://example.com/foo'));
|
||||
$this->assertEmpty($this->getStoreMetadata($requestHttp));
|
||||
$this->assertEmpty($this->getStoreMetadata($requestHttps));
|
||||
}
|
||||
|
||||
protected function storeSimpleEntry($path = null, $headers = array())
|
||||
{
|
||||
if (null === $path) {
|
||||
|
@ -1102,7 +1102,7 @@ class OptionsResolverTest extends TestCase
|
||||
$this->resolver->resolve();
|
||||
}
|
||||
|
||||
public function testCatchedExceptionFromNormalizerDoesNotCrashOptionResolver()
|
||||
public function testCaughtExceptionFromNormalizerDoesNotCrashOptionResolver()
|
||||
{
|
||||
$throw = true;
|
||||
|
||||
@ -1116,7 +1116,7 @@ class OptionsResolverTest extends TestCase
|
||||
}
|
||||
});
|
||||
|
||||
$this->resolver->setNormalizer('thrower', function (Options $options) use (&$throw) {
|
||||
$this->resolver->setNormalizer('thrower', function () use (&$throw) {
|
||||
if ($throw) {
|
||||
$throw = false;
|
||||
throw new \UnexpectedValueException('throwing');
|
||||
@ -1125,10 +1125,10 @@ class OptionsResolverTest extends TestCase
|
||||
return true;
|
||||
});
|
||||
|
||||
$this->resolver->resolve();
|
||||
$this->assertSame(array('catcher' => false, 'thrower' => true), $this->resolver->resolve());
|
||||
}
|
||||
|
||||
public function testCatchedExceptionFromLazyDoesNotCrashOptionResolver()
|
||||
public function testCaughtExceptionFromLazyDoesNotCrashOptionResolver()
|
||||
{
|
||||
$throw = true;
|
||||
|
||||
@ -1149,7 +1149,7 @@ class OptionsResolverTest extends TestCase
|
||||
return true;
|
||||
});
|
||||
|
||||
$this->resolver->resolve();
|
||||
$this->assertSame(array('catcher' => false, 'thrower' => true), $this->resolver->resolve());
|
||||
}
|
||||
|
||||
public function testInvokeEachNormalizerOnlyOnce()
|
||||
|
@ -87,7 +87,9 @@ class PropertyPathTest extends TestCase
|
||||
|
||||
public function testZeroIsValidPropertyPath()
|
||||
{
|
||||
new PropertyPath('0');
|
||||
$propertyPath = new PropertyPath('0');
|
||||
|
||||
$this->assertSame('0', (string) $propertyPath);
|
||||
}
|
||||
|
||||
public function testGetParentWithDot()
|
||||
|
@ -25,6 +25,8 @@ class TranslationFilesTest extends TestCase
|
||||
} else {
|
||||
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);
|
||||
}
|
||||
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function provideTranslationFiles()
|
||||
|
@ -319,6 +319,6 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface
|
||||
$this->logger->debug('Did not send remember-me cookie.', array('parameter' => $this->options['remember_me_parameter']));
|
||||
}
|
||||
|
||||
return $parameter === 'true' || $parameter === 'on' || $parameter === '1' || $parameter === 'yes';
|
||||
return $parameter === 'true' || $parameter === 'on' || $parameter === '1' || $parameter === 'yes' || $parameter === true;
|
||||
}
|
||||
}
|
||||
|
@ -251,6 +251,7 @@ class AbstractRememberMeServicesTest extends TestCase
|
||||
array('1'),
|
||||
array('on'),
|
||||
array('yes'),
|
||||
array(true),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@ use Symfony\Component\Serializer\Tests\Fixtures\NormalizableTraversableDummy;
|
||||
use Symfony\Component\Serializer\Tests\Fixtures\ScalarDummy;
|
||||
use Symfony\Component\Serializer\Encoder\XmlEncoder;
|
||||
use Symfony\Component\Serializer\Serializer;
|
||||
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
|
||||
use Symfony\Component\Serializer\Normalizer\CustomNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
@ -435,23 +434,12 @@ XML;
|
||||
$this->encoder->decode('<?xml version="1.0"?><invalid><xml>', 'xml');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
|
||||
*/
|
||||
public function testPreventsComplexExternalEntities()
|
||||
{
|
||||
$oldCwd = getcwd();
|
||||
chdir(__DIR__);
|
||||
|
||||
try {
|
||||
$this->encoder->decode('<?xml version="1.0"?><!DOCTYPE scan[<!ENTITY test SYSTEM "php://filter/read=convert.base64-encode/resource=XmlEncoderTest.php">]><scan>&test;</scan>', 'xml');
|
||||
chdir($oldCwd);
|
||||
|
||||
$this->fail('No exception was thrown.');
|
||||
} catch (\Exception $e) {
|
||||
chdir($oldCwd);
|
||||
|
||||
if (!$e instanceof UnexpectedValueException) {
|
||||
$this->fail('Expected UnexpectedValueException');
|
||||
}
|
||||
}
|
||||
$this->encoder->decode('<?xml version="1.0"?><!DOCTYPE scan[<!ENTITY test SYSTEM "php://filter/read=convert.base64-encode/resource=XmlEncoderTest.php">]><scan>&test;</scan>', 'xml');
|
||||
}
|
||||
|
||||
public function testDecodeEmptyXml()
|
||||
|
@ -65,7 +65,6 @@ class PluralizationRulesTest extends TestCase
|
||||
array('2', array('nl', 'fr', 'en', 'de', 'de_GE', 'hy', 'hy_AM')),
|
||||
array('3', array('be', 'bs', 'cs', 'hr')),
|
||||
array('4', array('cy', 'mt', 'sl')),
|
||||
array('5', array()),
|
||||
array('6', array('ar')),
|
||||
);
|
||||
}
|
||||
@ -86,7 +85,6 @@ class PluralizationRulesTest extends TestCase
|
||||
array('3', array('cbs')),
|
||||
array('4', array('gd', 'kw')),
|
||||
array('5', array('ga')),
|
||||
array('6', array()),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -156,6 +156,7 @@ class TranslatorTest extends TestCase
|
||||
$translator = new Translator($locale, new MessageSelector());
|
||||
$translator->setFallbackLocales(array('fr', $locale));
|
||||
// no assertion. this method just asserts that no exception is thrown
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function testTransWithFallbackLocale()
|
||||
@ -187,6 +188,7 @@ class TranslatorTest extends TestCase
|
||||
$translator = new Translator('fr', new MessageSelector());
|
||||
$translator->addResource('array', array('foo' => 'foofoo'), $locale);
|
||||
// no assertion. this method just asserts that no exception is thrown
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function testAddResourceAfterTrans()
|
||||
@ -390,6 +392,7 @@ class TranslatorTest extends TestCase
|
||||
|
||||
$translator->transChoice('foo', 1, array(), '', $locale);
|
||||
// no assertion. this method just asserts that no exception is thrown
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function getTransFileTests()
|
||||
|
@ -115,7 +115,9 @@ class ConstraintTest extends TestCase
|
||||
|
||||
public function testRequiredOptionsPassed()
|
||||
{
|
||||
new ConstraintC(array('option1' => 'default'));
|
||||
$constraint = new ConstraintC(array('option1' => 'default'));
|
||||
|
||||
$this->assertSame('default', $constraint->option1);
|
||||
}
|
||||
|
||||
public function testGroupsAreConvertedToArray()
|
||||
@ -140,7 +142,9 @@ class ConstraintTest extends TestCase
|
||||
|
||||
public function testCanCreateConstraintWithNoDefaultOptionAndEmptyArray()
|
||||
{
|
||||
new ConstraintB(array());
|
||||
$constraint = new ConstraintB(array());
|
||||
|
||||
$this->assertSame(array(Constraint::PROPERTY_CONSTRAINT, Constraint::CLASS_CONSTRAINT), $constraint->getTargets());
|
||||
}
|
||||
|
||||
public function testGetTargetsCanBeString()
|
||||
|
@ -211,7 +211,9 @@ class CallbackValidatorTest extends ConstraintValidatorTestCase
|
||||
// Should succeed. Needed when defining constraints as annotations.
|
||||
public function testNoConstructorArguments()
|
||||
{
|
||||
new Callback();
|
||||
$constraint = new Callback();
|
||||
|
||||
$this->assertSame(array(Constraint::CLASS_CONSTRAINT, Constraint::PROPERTY_CONSTRAINT), $constraint->getTargets());
|
||||
}
|
||||
|
||||
public function testAnnotationInvocationSingleValued()
|
||||
|
@ -245,19 +245,23 @@ class ClassMetadataTest extends TestCase
|
||||
public function testGroupSequencesWorkIfContainingDefaultGroup()
|
||||
{
|
||||
$this->metadata->setGroupSequence(array('Foo', $this->metadata->getDefaultGroup()));
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\Validator\Constraints\GroupSequence', $this->metadata->getGroupSequence());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\GroupDefinitionException
|
||||
*/
|
||||
public function testGroupSequencesFailIfNotContainingDefaultGroup()
|
||||
{
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\GroupDefinitionException');
|
||||
|
||||
$this->metadata->setGroupSequence(array('Foo', 'Bar'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\GroupDefinitionException
|
||||
*/
|
||||
public function testGroupSequencesFailIfContainingDefault()
|
||||
{
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\GroupDefinitionException');
|
||||
|
||||
$this->metadata->setGroupSequence(array('Foo', $this->metadata->getDefaultGroup(), Constraint::DEFAULT_GROUP));
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,11 @@ class LazyLoadingMetadataFactoryTest extends TestCase
|
||||
$metadata = $factory->getMetadataFor(self::PARENT_CLASS);
|
||||
$metadata->addConstraint(new Callback(function () {}));
|
||||
|
||||
$this->assertCount(3, $metadata->getConstraints());
|
||||
|
||||
$metadata = $factory->getMetadataFor(self::CLASS_NAME);
|
||||
|
||||
$this->assertCount(6, $metadata->getConstraints());
|
||||
}
|
||||
|
||||
public function testGroupsFromParent()
|
||||
|
@ -25,6 +25,8 @@ class TranslationFilesTest extends TestCase
|
||||
} else {
|
||||
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);
|
||||
}
|
||||
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function provideTranslationFiles()
|
||||
|
Reference in New Issue
Block a user