8000 Fix tests by Seldaek · Pull Request #3438 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Fix tests #3438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 24, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public function testValidationPaths()

$xmlArgs = $container->getParameter('validator.mapping.loader.xml_files_loader.mapping_files');
$this->assertCount(2, $xmlArgs);
$this->assertStringEndsWith('Component/Form/Resources/config/validation.xml', $xmlArgs[0]);
$this->assertStringEndsWith('Component/Form/Resources/config/validation.xml', strtr($xmlArgs[0], '\\', '/'));
$this->assertStringEndsWith('TestBundle'.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'validati 8000 on.xml', $xmlArgs[1]);
}

Expand Down
< 8000 td id="diff-3c46efe32dfb6e89ec745b08f6b7e2029b9462e2c835194aad80695b9179b0adL71" data-line-number="71" class="blob-num blob-num-context js-linkable-line-number">
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
*/
public function testCreateMap($directory, $expected)
{
$this->assertEquals($expected, ClassMapGenerator::createMap($directory));
$this->assertEqualsNormalized($expected, ClassMapGenerator::createMap($directory));
}

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

$this->assertEquals(array(
$this->assertEqualsNormalized(array(
'NamespaceCollision\\A\\B\\Bar' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Bar.php',
'NamespaceCollision\\A\\B\\Foo' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Foo.php',
), ClassMapGenerator::createMap($finder));
}

protected function assertEqualsNormalized($expected, $actual, $message = null)
{
foreach ($expected as $ns => $path) {
$expected[$ns] = strtr($path, '\\', '/');
}
foreach ($actual as $ns => $path) {
$actual[$ns] = strtr($path, '\\', '/');
}
$this->assertEquals($expected, $actual, $message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public function testTotalTime()
{
$event = new StopwatchEvent(microtime(true) * 1000);
$event->start();
usleep(10000);
usleep(20000);
$event->stop();
$total = $event->getTotalTime();
$this->assertTrue($total >= 9 && $total <= 20);
$this->assertTrue($total > 10 && $total <= 29, $total.' should be 20 (between 10 and 29)');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming is inconsistent. Here is means higher than 10 (exclusive 10) and in line 104 is means inclusive 21.
Btw, these test still fail on my windows. I get higher values, e.g. 31.4.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please send a PR if you really think this matters - sorry but I can't see this file anymore :) And yeah I'm sure it still will fail every now and then, but hopefully rarely enough that it is not too distracting when developing. The only solution would be to increase the sleeps so that small inaccuracies become less relevant, but that makes running the tests annoying too.


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

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

public function testStartTime()
Expand Down Expand Up @@ -139,7 +139,7 @@ public function testEndTime()
usleep(10000);
$event->stop();
$end = $event->getEndTime();
$this->assertTrue($end >= 18 && $end <= 30);
$this->assertTrue($end > 10 && $end <= 29, $end.' should be 20 (between 10 and 29)');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public function testStop()
{
$stopwatch = new Stopwatch();
$stopwatch->start('foo', 'cat');
usleep(10000);
usleep(20000);
$event = $stopwatch->stop('foo');

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

public function testLap()
Expand All @@ -52,7 +52,7 @@ public function testLap()

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ protected function setUp()
self::$storage = new DummyMemcacheProfilerStorage('memcache://127.0.0.1/11211', '', '', 86400);
try {
self::$storage->getMemcache();
$stats = self::$storage->getMemcache()->getExtendedStats();
if (!isset($stats['127.0.0.1:11211']) || $stats['127.0.0.1:11211'] === false) {
throw new \Exception();
}
} catch(\Exception $e) {
$this->markTestSkipped('MemcacheProfilerStorageTest requires that there is a Memcache server present on localhost');
}
Expand Down
0