10000 merged branch Seldaek/fixtests (PR #3438) · symfony/symfony@a1370c9 · GitHub
[go: up one dir, main page]

Skip to content

Commit a1370c9

Browse files
committed
merged branch Seldaek/fixtests (PR #3438)
Commits ------- e67f8d4 Properly skip memcached tests when no memcached server is present 005d86f Broaden timer tests limits 001c4fd Fix windows fs tests Discussion ---------- Fix tests - Some windows fixes - Skip memcached for real when it's not there - by the way I think those tests are insane since they seem to run a purge() on the memcached server. If you run this by accident somewhere where it matters it could hurt. I think they should be put in a group disabled by default, I'll be happy to add that change if it's deemed useful. - Fixed the timer tests for good on windows (which seems to be quite bad at `usleep`). I also documented them so you actually know how it failed when it does, the false instead of true wasn't super useful.
2 parents 88b40e9 + e67f8d4 commit a1370c9

File tree

5 files changed

+26
-11
lines changed

5 files changed

+26
-11
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public function testValidationPaths()
231231

232232
$xmlArgs = $container->getParameter('validator.mapping.loader.xml_files_loader.mapping_files');
233233
$this->assertCount(2, $xmlArgs);
234-
$this->assertStringEndsWith('Component/Form/Resources/config/validation.xml', $xmlArgs[0]);
234+
$this->assertStringEndsWith('Component/Form/Resources/config/validation.xml', strtr($xmlArgs[0], '\\', '/'));
235235
$this->assertStringEndsWith('TestBundle'.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'validation.xml', $xmlArgs[1]);
236236
}
237237

tests/Symfony/Tests/Component/ClassLoader/ClassMapGeneratorTest.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
2121
*/
2222
public function testCreateMap($directory, $expected)
2323
{
24-
$this->assertEquals($expected, ClassMapGenerator::createMap($directory));
24+
$this->assertEqualsNormalized($expected, ClassMapGenerator::createMap($directory));
2525
}
2626

2727
public function getTestCreateMapTests()
@@ -65,9 +65,20 @@ public function testCreateMapFinderSupport()
6565
$finder = new \Symfony\Component\Finder\Finder();
6666
$finder->files()->in(__DIR__ . '/Fixtures/beta/NamespaceCollision');
6767

68-
$this->assertEquals(array(
68+
$this->assertEqualsNormalized(array(
6969
'NamespaceCollision\\A\\B\\Bar' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Bar.php',
7070
'NamespaceCollision\\A\\B\\Foo' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Foo.php',
7171
), ClassMapGenerator::createMap($finder));
7272
}
73+
74+
protected function assertEqualsNormalized($expected, $actual, $message = null)
75+
{
76+
foreach ($expected as $ns => $path) {
77+
$expected[$ns] = strtr($path, '\\', '/');
78+
}
79+
foreach ($actual as $ns => $path) {
80+
$actual[$ns] = strtr($path, '\\', '/');
81+
}
82+
$this->assertEquals($expected, $actual, $message);
83+
}
7384
}

tests/Symfony/Tests/Component/HttpKernel/Debug/StopwatchEventTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ public function testTotalTime()
6666
{
6767
$event = new StopwatchEvent(microtime(true) * 1000);
6868
$event->start();
69-
usleep(10000);
69+
usleep(20000);
7070
$event->stop();
7171
$total = $event->getTotalTime();
72-
$this->assertTrue($total >= 9 && $total <= 20);
72+
$this->assertTrue($total > 10 && $total <= 29, $total.' should be 20 (between 10 and 29)');
7373

7474
$event = new StopwatchEvent(microtime(true) * 1000);
7575
$event->start();
@@ -79,7 +79,7 @@ public function testTotalTime()
7979
usleep(10000);
8080
$event->stop();
8181
$total = $event->getTotalTime();
82-
$this->assertTrue($total >= 18 && $total <= 30);
82+
$this->assertTrue($total > 10 && $total <= 29, $total.' should be 20 (between 10 and 29)');
8383
}
8484

8585
/**
@@ -101,7 +101,7 @@ public function testEnsureStopped()
101101
usleep(10000);
102102
$event->ensureStopped();
103103
$total = $event->getTotalTime();
104-
$this->assertTrue($total >= 27 && $total <= 40);
104+
$this->assertTrue($total >= 21 && $total <= 39, $total.' should be 30 (between 21 and 39)');
105105
}
106106

107107
public function testStartTime()
@@ -139,7 +139,7 @@ public function testEndTime()
139139
usleep(10000);
140140
$event->stop();
141141
$end = $event->getEndTime();
142-
$this->assertTrue($end >= 18 && $end <= 30);
142+
$this->assertTrue($end > 10 && $end <= 29, $end.' should be 20 (between 10 and 29)');
143143
}
144144

145145
/**

tests/Symfony/Tests/Component/HttpKernel/Debug/StopwatchTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ public function testStop()
3333
{
3434
$stopwatch = new Stopwatch();
3535
$stopwatch->start('foo', 'cat');
36-
usleep(10000);
36+
usleep(20000);
3737
$event = $stopwatch->stop('foo');
3838

3939
$this->assertInstanceof('Symfony\Component\HttpKernel\Debug\StopwatchEvent', $event);
4040
$total = $event->getTotalTime();
41-
$this->assertTrue($total >= 9 && $total <= 20);
41+
$this->assertTrue($total > 10 && $total <= 29, $total.' should be 20 (between 10 and 29)');
4242
}
4343

4444
public function testLap()
@@ -52,7 +52,7 @@ public function testLap()
5252

5353
$this->assertInstanceof('Symfony\Component\HttpKernel\Debug\StopwatchEvent', $event);
5454
$total = $event->getTotalTime();
55-
$this->assertTrue($total >= 18 && $total <= 30);
55+
$this->assertTrue($total > 10 && $total <= 29, $total.' should be 20 (between 10 and 29)');
5656
}
5757

5858
/**

tests/Symfony/Tests/Component/HttpKernel/Profiler/MemcacheProfilerStorageTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ protected function setUp()
4242
self::$storage = new DummyMemcacheProfilerStorage('memcache://127.0.0.1/11211', '', '', 86400);
4343
try {
4444
self::$storage->getMemcache();
45+
$stats = self::$storage->getMemcache()->getExtendedStats();
46+
if (!isset($stats['127.0.0.1:11211']) || $stats['127.0.0.1:11211'] === false) {
47+
throw new \Exception();
48+
}
4549
} catch(\Exception $e) {
4650
$this->markTestSkipped('MemcacheProfilerStorageTest requires that there is a Memcache server present on localhost');
4751
}

0 commit comments

Comments
 (0)
0