added missing tests from previous merge
This commit is contained in:
parent
e425f6cf9a
commit
9c38e768d9
@ -89,7 +89,7 @@ class InputArgumentTest extends \PHPUnit_Framework_TestCase
|
||||
$this->fail('->setDefault() throws a \LogicException if you give a default value for a required argument');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\LogicException', $e, '->setDefault() throws a \LogicException exception if an invalid option is passed');
|
||||
$this->assertEquals('Cannot set a default value except for Parameter::OPTIONAL mode.', $e->getMessage());
|
||||
$this->assertEquals('Cannot set a default value except for InputArgument::OPTIONAL mode.', $e->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -154,7 +154,7 @@ class InputOptionTest extends \PHPUnit_Framework_TestCase
|
||||
$this->fail('->setDefault() throws a \LogicException if you give a default value for a VALUE_NONE option');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\LogicException', $e, '->setDefault() throws a \LogicException if you give a default value for a VALUE_NONE option');
|
||||
$this->assertEquals('Cannot set a default value when using Option::VALUE_NONE mode.', $e->getMessage());
|
||||
$this->assertEquals('Cannot set a default value when using InputOption::VALUE_NONE mode.', $e->getMessage());
|
||||
}
|
||||
|
||||
$option = new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY);
|
||||
|
@ -86,14 +86,104 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase
|
||||
{
|
||||
$transformer = new NumberToLocalizedStringTransformer(null, true);
|
||||
|
||||
// completely valid format
|
||||
$this->assertEquals(1234.5, $transformer->reverseTransform('1.234,5'));
|
||||
$this->assertEquals(12345.912, $transformer->reverseTransform('12.345,912'));
|
||||
// omit group separator
|
||||
$this->assertEquals(1234.5, $transformer->reverseTransform('1234,5'));
|
||||
$this->assertEquals(12345.912, $transformer->reverseTransform('12345,912'));
|
||||
}
|
||||
|
||||
public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsNotDot()
|
||||
{
|
||||
\Locale::setDefault('fr');
|
||||
$transformer = new NumberToLocalizedStringTransformer(null, true);
|
||||
|
||||
// completely valid format
|
||||
$this->assertEquals(1234.5, $transformer->reverseTransform('1 234,5'));
|
||||
// accept dots
|
||||
$this->assertEquals(1234.5, $transformer->reverseTransform('1 234.5'));
|
||||
// omit group separator
|
||||
$this->assertEquals(1234.5, $transformer->reverseTransform('1234,5'));
|
||||
$this->assertEquals(1234.5, $transformer->reverseTransform('1234.5'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Form\Exception\UnexpectedTypeException
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot()
|
||||
{
|
||||
$transformer = new NumberToLocalizedStringTransformer(null, true);
|
||||
|
||||
$transformer->reverseTransform('1.234.5');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot_noGroupSep()
|
||||
{
|
||||
$transformer = new NumberToLocalizedStringTransformer(null, true);
|
||||
|
||||
$transformer->reverseTransform('1234.5');
|
||||
}
|
||||
|
||||
public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsDotButNoGroupingUsed()
|
||||
{
|
||||
\Locale::setDefault('fr');
|
||||
$transformer = new NumberToLocalizedStringTransformer();
|
||||
|
||||
$this->assertEquals(1234.5, $transformer->reverseTransform('1234,5'));
|
||||
$this->assertEquals(1234.5, $transformer->reverseTransform('1234.5'));
|
||||
}
|
||||
|
||||
public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsNotComma()
|
||||
{
|
||||
\Locale::setDefault('ak');
|
||||
$transformer = new NumberToLocalizedStringTransformer(null, true);
|
||||
|
||||
// completely valid format
|
||||
$this->assertEquals(1234.5, $transformer->reverseTransform('1 234.5'));
|
||||
// accept commas
|
||||
$this->assertEquals(1234.5, $transformer->reverseTransform('1 234,5'));
|
||||
// omit group separator
|
||||
$this->assertEquals(1234.5, $transformer->reverseTransform('1234.5'));
|
||||
$this->assertEquals(1234.5, $transformer->reverseTransform('1234,5'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma()
|
||||
{
|
||||
\Locale::setDefault('en');
|
||||
$transformer = new NumberToLocalizedStringTransformer(null, true);
|
||||
|
||||
$transformer->reverseTransform('1,234,5');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma_noGroupSep()
|
||||
{
|
||||
\Locale::setDefault('en');
|
||||
$transformer = new NumberToLocalizedStringTransformer(null, true);
|
||||
|
||||
$transformer->reverseTransform('1234,5');
|
||||
}
|
||||
|
||||
public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsCommaButNoGroupingUsed()
|
||||
{
|
||||
\Locale::setDefault('en');
|
||||
$transformer = new NumberToLocalizedStringTransformer();
|
||||
|
||||
$this->assertEquals(1234.5, $transformer->reverseTransform('1234,5'));
|
||||
$this->assertEquals(1234.5, $transformer->reverseTransform('1234.5'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testTransformExpectsNumeric()
|
||||
{
|
||||
@ -103,7 +193,7 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Form\Exception\UnexpectedTypeException
|
||||
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testReverseTransformExpectsString()
|
||||
{
|
||||
@ -113,7 +203,7 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Form\Exception\TransformationFailedException
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testReverseTransformExpectsValidNumber()
|
||||
{
|
||||
@ -123,7 +213,7 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Form\Exception\TransformationFailedException
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
* @link https://github.com/symfony/symfony/issues/3161
|
||||
*/
|
||||
public function testReverseTransformDisallowsNaN()
|
||||
@ -134,7 +224,7 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Form\Exception\TransformationFailedException
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testReverseTransformDisallowsNaN2()
|
||||
{
|
||||
@ -144,7 +234,7 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Form\Exception\TransformationFailedException
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testReverseTransformDisallowsInfinity()
|
||||
{
|
||||
@ -154,7 +244,7 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Form\Exception\TransformationFailedException
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testReverseTransformDisallowsInfinity2()
|
||||
{
|
||||
@ -164,7 +254,7 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Form\Exception\TransformationFailedException
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testReverseTransformDisallowsNegativeInfinity()
|
||||
{
|
||||
|
@ -91,6 +91,41 @@ class FileTest extends \PHPUnit_Framework_TestCase
|
||||
@unlink($targetPath);
|
||||
}
|
||||
|
||||
public function getFilenameFixtures()
|
||||
{
|
||||
return array(
|
||||
array('original.gif', 'original.gif'),
|
||||
array('..\\..\\original.gif', 'original.gif'),
|
||||
array('../../original.gif', 'original.gif'),
|
||||
array('файлfile.gif', 'файлfile.gif'),
|
||||
array('..\\..\\файлfile.gif', 'файлfile.gif'),
|
||||
array('../../файлfile.gif', 'файлfile.gif'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getFilenameFixtures
|
||||
*/
|
||||
public function testMoveWithNonLatinName($filename, $sanitizedFilename)
|
||||
{
|
||||
$path = __DIR__.'/Fixtures/'.$sanitizedFilename;
|
||||
$targetDir = __DIR__.'/Fixtures/directory/';
|
||||
$targetPath = $targetDir.$sanitizedFilename;
|
||||
@unlink($path);
|
||||
@unlink($targetPath);
|
||||
copy(__DIR__.'/Fixtures/test.gif', $path);
|
||||
|
||||
$file = new File($path);
|
||||
$movedFile = $file->move($targetDir,$filename);
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\File\File', $movedFile);
|
||||
|
||||
$this->assertTrue(file_exists($targetPath));
|
||||
$this->assertFalse(file_exists($path));
|
||||
$this->assertEquals(realpath($targetPath), $movedFile->getRealPath());
|
||||
|
||||
@unlink($targetPath);
|
||||
}
|
||||
|
||||
public function testMoveToAnUnexistentDirectory()
|
||||
{
|
||||
$sourcePath = __DIR__.'/Fixtures/test.copy.gif';
|
||||
|
@ -49,6 +49,19 @@ class StoreTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEmpty($this->getStoreMetadata('/nothing'));
|
||||
}
|
||||
|
||||
public function testUnlockFileThatDoesExist()
|
||||
{
|
||||
$cacheKey = $this->storeSimpleEntry();
|
||||
$this->store->lock($this->request);
|
||||
|
||||
$this->assertTrue($this->store->unlock($this->request));
|
||||
}
|
||||
|
||||
public function testUnlockFileThatDoesNotExist()
|
||||
{
|
||||
$this->assertFalse($this->store->unlock($this->request));
|
||||
}
|
||||
|
||||
public function testRemovesEntriesForKeyWithPurge()
|
||||
{
|
||||
$request = Request::create('/foo');
|
||||
|
Reference in New Issue
Block a user