From 73be61c8947258e9f9ba7dd525aca0b8e242bf11 Mon Sep 17 00:00:00 2001 From: Michal Piotrowski Date: Sun, 8 Nov 2015 16:53:13 +0100 Subject: [PATCH 1/4] PhpUnit tests coverage p1 PhpUnit tests coverage p2 PhpUnit tests coverage p3 PhpUnit tests coverage p4 PhpUnit tests coverage p5 PhpUnit tests coverage p6 PhpUnit tests coverage p7 --- composer.json | 1 + phpunit.xml.dist | 1 + src/Symfony/Bridge/PhpUnit/ClockMock.php | 2 +- .../Bridge/PhpUnit/Tests/ClockMockTest.php | 87 +++++++++++++++++++ .../Tests/DeprecationErrorHandlerTest.php | 33 +++++++ src/Symfony/Bridge/PhpUnit/phpunit.xml.dist | 1 + 6 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Bridge/PhpUnit/Tests/ClockMockTest.php create mode 100644 src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandlerTest.php diff --git a/composer.json b/composer.json index 5fcec2e747e42..807310544861f 100644 --- a/composer.json +++ b/composer.json @@ -94,6 +94,7 @@ "psr-4": { "Symfony\\Bridge\\Doctrine\\": "src/Symfony/Bridge/Doctrine/", "Symfony\\Bridge\\Monolog\\": "src/Symfony/Bridge/Monolog/", + "Symfony\\Bridge\\PhpUnit\\": "src/Symfony/Bridge/PhpUnit/", "Symfony\\Bridge\\ProxyManager\\": "src/Symfony/Bridge/ProxyManager/", "Symfony\\Bridge\\Swiftmailer\\": "src/Symfony/Bridge/Swiftmailer/", "Symfony\\Bridge\\Twig\\": "src/Symfony/Bridge/Twig/", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 726b91ef23668..f61f4fbbeee91 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -40,6 +40,7 @@ ./src/Symfony/Bundle/*/Resources ./src/Symfony/Component/*/Resources ./src/Symfony/Component/*/*/Resources + ./src/Symfony/Bridge/PhpUnit/bootstrap.php diff --git a/src/Symfony/Bridge/PhpUnit/ClockMock.php b/src/Symfony/Bridge/PhpUnit/ClockMock.php index 4b745e38e87fc..b81fee965880a 100644 --- a/src/Symfony/Bridge/PhpUnit/ClockMock.php +++ b/src/Symfony/Bridge/PhpUnit/ClockMock.php @@ -66,7 +66,7 @@ public static function microtime($asFloat = false) return self::$now; } - return sprintf("%0.6f %d\n", $now - (int) $now, (int) self::$now); + return sprintf("%0.6f %d\n", self::$now - (int) self::$now, (int) self::$now); } public static function register($class) diff --git a/src/Symfony/Bridge/PhpUnit/Tests/ClockMockTest.php b/src/Symfony/Bridge/PhpUnit/Tests/ClockMockTest.php new file mode 100644 index 0000000000000..4a55e0661e441 --- /dev/null +++ b/src/Symfony/Bridge/PhpUnit/Tests/ClockMockTest.php @@ -0,0 +1,87 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\PhpUnit\Tests; + +use Symfony\Bridge\PhpUnit\ClockMock; + +class ClockMockTest extends \PHPUnit_Framework_TestCase +{ + public function testTimeNowNull() + { + $this->assertTrue(is_int(ClockMock::time())); + } + + public function testSleepNowNull() + { + $this->assertEquals(0, ClockMock::sleep(0)); + } + + public function testUsleepNowNull() + { + $this->assertNull(ClockMock::usleep(0)); + } + + public function testMicrotimeNowNull() + { + $this->assertTrue(is_float(ClockMock::microtime(true))); + } + + public function testWithClockMock() + { + $this->assertFalse(ClockMock::withClockMock()); + } + + public function testTime() + { + ClockMock::withClockMock(true); + + $this->assertTrue(is_int(ClockMock::time())); + } + + public function testSleep() + { + $this->assertEquals(0, ClockMock::sleep(0)); + } + + public function testUsleep() + { + $this->assertNull(ClockMock::usleep(0)); + } + + public function testMicrotimeTrue() + { + $this->assertTrue(is_float(ClockMock::microtime(true))); + } + + public function testMicrotime() + { + $res = explode(" ", ClockMock::microtime()); + + $this->assertTrue(is_float((float) $res[0])); + $this->assertTrue(is_int((integer) $res[1])); + } + + public function testWithClockMockTrue() + { + $this->assertNull(ClockMock::withClockMock(true)); + } + + public function testRegisterNormalClass() + { + $this->assertNull(ClockMock::register("Symfony\Bridge\PhpUnit\ClockMock")); + } + + public function testRegisterTestsClass() + { + $this->assertNull(ClockMock::register("Symfony\Bridge\PhpUnit\Tests\ClockMockTest")); + } +} diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandlerTest.php b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandlerTest.php new file mode 100644 index 0000000000000..ff253cbba73ec --- /dev/null +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandlerTest.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\PhpUnit\Tests; + +use Symfony\Bridge\PhpUnit\DeprecationErrorHandler; + +class DeprecationErrorHandlerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider provideRegisterParameters + */ + public function testRegisterFalse($mode) + { + $this->assertNull(DeprecationErrorHandler::register($mode)); + } + + public function provideRegisterParameters() + { + return array( + array(false), + array(true), + ); + } +} diff --git a/src/Symfony/Bridge/PhpUnit/phpunit.xml.dist b/src/Symfony/Bridge/PhpUnit/phpunit.xml.dist index 7f631b2ece48b..92edd72fd010c 100644 --- a/src/Symfony/Bridge/PhpUnit/phpunit.xml.dist +++ b/src/Symfony/Bridge/PhpUnit/phpunit.xml.dist @@ -22,6 +22,7 @@ ./Tests ./vendor + ./bootstrap.php From 309c08aa5c6978bb6a4be3b6b7a521dae1d1da49 Mon Sep 17 00:00:00 2001 From: Michal Piotrowski Date: Tue, 10 Nov 2015 00:04:32 +0100 Subject: [PATCH 2/4] changes requested by nicolas-grekas --- composer.json | 1 - phpunit.xml.dist | 1 - src/Symfony/Bridge/PhpUnit/Tests/ClockMockTest.php | 14 ++++++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 807310544861f..5fcec2e747e42 100644 --- a/composer.json +++ b/composer.json @@ -94,7 +94,6 @@ "psr-4": { "Symfony\\Bridge\\Doctrine\\": "src/Symfony/Bridge/Doctrine/", "Symfony\\Bridge\\Monolog\\": "src/Symfony/Bridge/Monolog/", - "Symfony\\Bridge\\PhpUnit\\": "src/Symfony/Bridge/PhpUnit/", "Symfony\\Bridge\\ProxyManager\\": "src/Symfony/Bridge/ProxyManager/", "Symfony\\Bridge\\Swiftmailer\\": "src/Symfony/Bridge/Swiftmailer/", "Symfony\\Bridge\\Twig\\": "src/Symfony/Bridge/Twig/", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index f61f4fbbeee91..726b91ef23668 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -40,7 +40,6 @@ ./src/Symfony/Bundle/*/Resources ./src/Symfony/Component/*/Resources ./src/Symfony/Component/*/*/Resources - ./src/Symfony/Bridge/PhpUnit/bootstrap.php diff --git a/src/Symfony/Bridge/PhpUnit/Tests/ClockMockTest.php b/src/Symfony/Bridge/PhpUnit/Tests/ClockMockTest.php index 4a55e0661e441..ffa95e79552e1 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/ClockMockTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/ClockMockTest.php @@ -49,12 +49,22 @@ public function testTime() public function testSleep() { - $this->assertEquals(0, ClockMock::sleep(0)); + $sleep = 10000; + $t1 = ClockMock::time(); + $this->assertEquals(0, ClockMock::sleep($sleep)); + $t2 = ClockMock::time(); + + $this->assertLessThanOrEqual($sleep, $t2 - $t1); } public function testUsleep() { - $this->assertNull(ClockMock::usleep(0)); + $sleep = 1000000; + $t1 = ClockMock::time(); + $this->assertNull(ClockMock::usleep($sleep)); + $t2 = ClockMock::time(); + + $this->assertLessThanOrEqual($sleep / 1000000, $t2 - $t1); } public function testMicrotimeTrue() From ca5d050b8e57a471b60a4ce092ea976cf8ca1cb1 Mon Sep 17 00:00:00 2001 From: Michal Piotrowski Date: Tue, 24 Nov 2015 22:15:45 +0100 Subject: [PATCH 3/4] remove test --- .../Tests/DeprecationErrorHandlerTest.php | 33 ------------------- 1 file changed, 33 deletions(-) delete mode 100644 src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandlerTest.php diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandlerTest.php b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandlerTest.php deleted file mode 100644 index ff253cbba73ec..0000000000000 --- a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandlerTest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PhpUnit\Tests; - -use Symfony\Bridge\PhpUnit\DeprecationErrorHandler; - -class DeprecationErrorHandlerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @dataProvider provideRegisterParameters - */ - public function testRegisterFalse($mode) - { - $this->assertNull(DeprecationErrorHandler::register($mode)); - } - - public function provideRegisterParameters() - { - return array( - array(false), - array(true), - ); - } -} From 9f3abfa3b82919eae25f8cbaef09b01bd3cb1e38 Mon Sep 17 00:00:00 2001 From: Michal Piotrowski Date: Tue, 24 Nov 2015 22:19:51 +0100 Subject: [PATCH 4/4] remove test and revert phpunit.xml.dist change --- .../Bridge/PhpUnit/Tests/ClockMockTest.php | 97 ------------------- src/Symfony/Bridge/PhpUnit/phpunit.xml.dist | 1 - 2 files changed, 98 deletions(-) delete mode 100644 src/Symfony/Bridge/PhpUnit/Tests/ClockMockTest.php diff --git a/src/Symfony/Bridge/PhpUnit/Tests/ClockMockTest.php b/src/Symfony/Bridge/PhpUnit/Tests/ClockMockTest.php deleted file mode 100644 index ffa95e79552e1..0000000000000 --- a/src/Symfony/Bridge/PhpUnit/Tests/ClockMockTest.php +++ /dev/null @@ -1,97 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PhpUnit\Tests; - -use Symfony\Bridge\PhpUnit\ClockMock; - -class ClockMockTest extends \PHPUnit_Framework_TestCase -{ - public function testTimeNowNull() - { - $this->assertTrue(is_int(ClockMock::time())); - } - - public function testSleepNowNull() - { - $this->assertEquals(0, ClockMock::sleep(0)); - } - - public function testUsleepNowNull() - { - $this->assertNull(ClockMock::usleep(0)); - } - - public function testMicrotimeNowNull() - { - $this->assertTrue(is_float(ClockMock::microtime(true))); - } - - public function testWithClockMock() - { - $this->assertFalse(ClockMock::withClockMock()); - } - - public function testTime() - { - ClockMock::withClockMock(true); - - $this->assertTrue(is_int(ClockMock::time())); - } - - public function testSleep() - { - $sleep = 10000; - $t1 = ClockMock::time(); - $this->assertEquals(0, ClockMock::sleep($sleep)); - $t2 = ClockMock::time(); - - $this->assertLessThanOrEqual($sleep, $t2 - $t1); - } - - public function testUsleep() - { - $sleep = 1000000; - $t1 = ClockMock::time(); - $this->assertNull(ClockMock::usleep($sleep)); - $t2 = ClockMock::time(); - - $this->assertLessThanOrEqual($sleep / 1000000, $t2 - $t1); - } - - public function testMicrotimeTrue() - { - $this->assertTrue(is_float(ClockMock::microtime(true))); - } - - public function testMicrotime() - { - $res = explode(" ", ClockMock::microtime()); - - $this->assertTrue(is_float((float) $res[0])); - $this->assertTrue(is_int((integer) $res[1])); - } - - public function testWithClockMockTrue() - { - $this->assertNull(ClockMock::withClockMock(true)); - } - - public function testRegisterNormalClass() - { - $this->assertNull(ClockMock::register("Symfony\Bridge\PhpUnit\ClockMock")); - } - - public function testRegisterTestsClass() - { - $this->assertNull(ClockMock::register("Symfony\Bridge\PhpUnit\Tests\ClockMockTest")); - } -} diff --git a/src/Symfony/Bridge/PhpUnit/phpunit.xml.dist b/src/Symfony/Bridge/PhpUnit/phpunit.xml.dist index 92edd72fd010c..7f631b2ece48b 100644 --- a/src/Symfony/Bridge/PhpUnit/phpunit.xml.dist +++ b/src/Symfony/Bridge/PhpUnit/phpunit.xml.dist @@ -22,7 +22,6 @@ ./Tests ./vendor - ./bootstrap.php pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy