8000 added missing tests from previous merge · symfony/symfony@9c38e76 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9c38e76

Browse files
committed
added missing tests from previous merge
1 parent e425f6c commit 9c38e76

File tree

5 files changed

+148
-10
lines changed

5 files changed

+148
-10
lines changed

src/Symfony/Component/Console/Tests/Input/InputArgumentTest.php

Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function testSetDefault()
8989
$this->fail('->setDefault() throws a \LogicException if you give a default value for a required argument');
9090
} catch (\Exception $e) {
9191
$this->assertInstanceOf('\LogicException', $e, '->setDefault() throws a \LogicException exception if an invalid option is passed');
92-
$this->assertEquals('Cannot set a default value except for Parameter::OPTIONAL mode.', $e->getMessage());
92+
$this->assertEquals('Cannot set a default value except for InputArgument::OPTIONAL mode.', $e->getMessage());
9393
}
9494

9595
try {

src/Symfony/Component/Console/Tests/Input/InputOptionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public function testSetDefault()
154154
$this->fail('->setDefault() throws a \LogicException if you give a default value for a VALUE_NONE option');
155155
} catch (\Exception $e) {
156156
$this->assertInstanceOf('\LogicException', $e, '->setDefault() throws a \LogicException if you give a default value for a VALUE_NONE option');
157-
$this->assertEquals('Cannot set a default value when using Option::VALUE_NONE mode.', $e->getMessage());
157+
$this->assertEquals('Cannot set a default value when using InputOption::VALUE_NONE mode.', $e->getMessage());
158158
}
159159

160160
$option = new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY);

src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php

Lines changed: 98 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,104 @@ public function testReverseTransformWithGrouping()
8686
{
8787
$transformer = new NumberToLocalizedStringTransformer(null, true);
8888

89+
// completely valid format
8990
$this->assertEquals(1234.5, $transformer->reverseTransform('1.234,5'));
9091
$this->assertEquals(12345.912, $transformer->reverseTransform('12.345,912'));
92+
// omit group separator
9193
$this->assertEquals(1234.5, $transformer->reverseTransform('1234,5'));
9294
$this->assertEquals(12345.912, $transformer->reverseTransform('12345,912'));
9395
}
9496

97+
public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsNotDot()
98+
{
99+
\Locale::setDefault('fr');
100+
$transformer = new NumberToLocalizedStringTransformer(null, true);
101+
102+
// completely valid format
103+
$this->assertEquals(1234.5, $transformer->reverseTransform('1 234,5'));
104+
// accept dots
105+
$this->assertEquals(1234.5, $transformer->reverseTransform('1 234.5'));
106+
// omit group separator
107+
$this->assertEquals(1234.5, $transformer->reverseTransform('1234,5'));
108+
$this->assertEquals(1234.5, $transformer->reverseTransform('1234.5'));
109+
}
110+
111+
/**
112+
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
113+
*/
114+
public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot()
115+
{
116+
$transformer = new NumberToLocalizedStringTransformer(null, true);
117+
118+
$transformer->reverseTransform('1.234.5');
119+
}
120+
121+
/**
122+
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
123+
*/
124+
public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot_noGroupSep()
125+
{
126+
$transformer = new NumberToLocalizedStringTransformer(null, true);
127+
128+
$transformer->reverseTransform('1234.5');
129+
}
130+
131+
public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsDotButNoGroupingUsed()
132+
{
133+
\Locale::setDefault('fr');
134+
$transformer = new NumberToLocalizedStringTransformer();
135+
136+
$this->assertEquals(1234.5, $transformer->reverseTransform('1234,5'));
137+
$this->assertEquals(1234.5, $transformer->reverseTransform('1234.5'));
138+
}
139+
140+
public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsNotComma()
141+
{
142+
\Locale::setDefault('ak');
143+
$transformer = new NumberToLocalizedStringTransformer(null, true);
144+
145+
// completely valid format
146+
$this->assertEquals(1234.5, $transformer->reverseTransform('1 234.5'));
147+
// accept commas
148+
$this->assertEquals(1234.5, $transformer->reverseTransform('1 234,5'));
149+
// omit group separator
150+
$this->assertEquals(1234.5, $transformer->reverseTransform('1234.5'));
151+
$this->assertEquals(1234.5, $transformer->reverseTransform('1234,5'));
152+
}
153+
154+
/**
155+
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
156+
*/
157+
public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma()
158+
{
159+
\Locale::setDefault('en');
160+
$transformer = new NumberToLocalizedStringTransformer(null, true);
161+
162+
$transformer->reverseTransform('1,234,5');
163+
}
164+
165+
/**
166+
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
167+
*/
168+
public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma_noGroupSep()
169+
{
170+
\Locale::setDefault('en');
171+
$transformer = new NumberToLocalizedStringTransformer(null, true);
172+
173+
$transformer->reverseTransform('1234,5');
174+
}
175+
176+
public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsCommaButNoGroupingUsed()
177+
{
178+
\Locale::setDefault('en');
179+
$transformer = new NumberToLocalizedStringTransformer();
180+
181+
$this->assertEquals(1234.5, $transformer->reverseTransform('1234,5'));
182+
$this->assertEquals(1234.5, $transformer->reverseTransform('1234.5'));
183+
}
184+
95185
/**
96-
* @expectedException Symfony\Component\Form\Exception\UnexpectedTypeException
186+
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
97187
*/
98188
public function testTransformExpectsNumeric()
99189
{
@@ -103,7 +193,7 @@ public function testTransformExpectsNumeric()
103193
}
104194

105195
/**
106-
* @expectedException Symfony\Component\Form\Exception\UnexpectedTypeException
196+
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
107197
*/
108198
public function testReverseTransformExpectsString()
109199
{
@@ -113,7 +203,7 @@ public function testReverseTransformExpectsString()
113203
}
114204

115205
/**
116-
* @expectedException Symfony\Component\Form\Exception\TransformationFailedException
206+
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
117207
*/
118208
public function testReverseTransformExpectsValidNumber()
119209
{
@@ -123,7 +213,7 @@ public function testReverseTransformExpectsValidNumber()
123213
}
124214

125215
/**
126-
* @expectedException Symfony\Component\Form\Exception\TransformationFailedException
216+
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
127217
* @link https://github.com/symfony/symfony/issues/3161
128218
*/
129219
public function testReverseTransformDisallowsNaN()
@@ -134,7 +224,7 @@ public function testReverseTransformDisallowsNaN()
134224
}
135225

136226
/**
137-
* @expectedException Symfony\Component\Form\Exception\TransformationFailedException
227+
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
138228
*/
139229
public function testReverseTransformDisallowsNaN2()
140230
{
@@ -144,7 +234,7 @@ public function testReverseTransformDisallowsNaN2()
144234
}
145235

146236
/**
147-
* @expectedException Symfony\Component\Form\Exception\TransformationFailedException
237+
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
148238
*/
149239
public function testReverseTransformDisallowsInfinity()
150240
{
@@ -154,7 +244,7 @@ public function testReverseTransformDisallowsInfinity()
154244
}
155245

156246
/**
157-
* @expectedException Symfony\Component\Form\Exception\TransformationFailedException
247+
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
158248
*/
159249
public function testReverseTransformDisallowsInfinity2()
160250
{
@@ -164,7 +254,7 @@ public function testReverseTransformDisallowsInfinity2()
164254
}
165255

166256
/**
167-
* @expectedException Symfony\Component\Form\Exception\TransformationFailedException
257+
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
168258
*/
169259
public function testReverseTransformDisallowsNegativeInfinity()
170260
{

src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,41 @@ public function testMoveWithNewName()
9191
@unlink($targetPath);
9292
}
9393

94+
public function getFilenameFixtures()
95+
{
96+
return array(
97+
array('original.gif', 'original.gif'),
98+
array('..\\..\\original.gif', 'original.gif'),
99+
array('../../original.gif', 'original.gif'),
100+
array('файлfile.gif', 'файлfile.gif'),
101+
array('..\\..\\файлfile.gif', 'файлfile.gif'),
102+
array('../../файлfile.gif', 'файлfile.gif'),
103+
);
104+
}
105+
106+
/**
107+
* @dataProvider getFilenameFixtures
108+
*/
109+
public function testMoveWithNonLatinName($filename, $sanitizedFilename)
110+
{
111+
$path = __DIR__.'/Fixtures/'.$sanitizedFilename;
112+
$targetDir = __DIR__.'/Fixtures/directory/';
113+
$targetPath = $targetDir.$sanitizedFilename;
114+
@unlink($path);
115+
@unlink($targetPath);
116+
copy(__DIR__.'/Fixtures/test.gif', $path);
117+
118+
$file = new File($path);
119+
$movedFile = $file->move($targetDir,$filename);
120+
$this->assertInstanceOf('Symfony\Component\HttpFoundation\File\File', $movedFile);
121+
122+
$this->assertTrue(file_exists($targetPath));
123+
$this->assertFalse(file_exists($path));
124+
$this->assertEquals(realpath($targetPath), $movedFile->getRealPath());
125+
126+
@unlink($targetPath);
127+
}
128+
94129
public function testMoveToAnUnexistentDirectory()
95130
{
96131
$sourcePath = __DIR__.'/Fixtures/test.copy.gif';

src/Symfony/Component/HttpKernel/Tests/HttpCache/StoreTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ public function testReadsAnEmptyArrayWithReadWhenNothingCachedAtKey()
4949
$this->assertEmpty($this->getStoreMetadata('/nothing'));
5050
}
5151

52+
public function testUnlockFileThatDoesExist()
53+
{
54+
$cacheKey = $this->storeSimpleEntry();
55+
$this->store->lock($this->request);
56+
57+
$this->assertTrue($this->store->unlock($this->request));
58+
}
59+
60+
public function testUnlockFileThatDoesNotExist()
61+
{
62+
$this->assertFalse($this->store->unlock($this->request));
63+
}
64+
5265
public function testRemovesEntriesForKeyWithPurge()
5366
{
5467
$request = Request::create('/foo');

0 commit comments

Comments
 (0)
0