From 8f233d21f1247b435da51d07f389ce859dffe47b Mon Sep 17 00:00:00 2001 From: Denis Portnov Date: Wed, 18 Jul 2012 23:13:32 +0400 Subject: [PATCH 1/2] more work on tests --- test/BigInteger/Adapter/BcmathTest.php | 11 +++++++++++ test/BigInteger/Adapter/GmpTest.php | 10 ++++++++++ test/BigInteger/BigIntegerTest.php | 14 +++----------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/test/BigInteger/Adapter/BcmathTest.php b/test/BigInteger/Adapter/BcmathTest.php index 7e89a2f..c0ea147 100644 --- a/test/BigInteger/Adapter/BcmathTest.php +++ b/test/BigInteger/Adapter/BcmathTest.php @@ -29,4 +29,15 @@ public function setUp() $this->adapter = new Bcmath(); } + + public function tearDown() + { + $this->adapter = null; + } + + /** + * Bcmath adapter test uses common test methods and data providers + * inherited from abstract @see AbstractTestCase + */ + } diff --git a/test/BigInteger/Adapter/GmpTest.php b/test/BigInteger/Adapter/GmpTest.php index 5881aca..a0e248b 100644 --- a/test/BigInteger/Adapter/GmpTest.php +++ b/test/BigInteger/Adapter/GmpTest.php @@ -29,4 +29,14 @@ public function setUp() $this->adapter = new Gmp(); } + + public function tearDown() + { + $this->adapter = null; + } + + /** + * Gmp adapter test uses common test methods and data providers + * inherited from abstract @see AbstractTestCase + */ } \ No newline at end of file diff --git a/test/BigInteger/BigIntegerTest.php b/test/BigInteger/BigIntegerTest.php index 2070f1e..822e510 100644 --- a/test/BigInteger/BigIntegerTest.php +++ b/test/BigInteger/BigIntegerTest.php @@ -22,17 +22,6 @@ */ class BigIntegerTest extends \PHPUnit_Framework_TestCase { - protected $adapters = array(); - - protected $availableAdapter = null; - - public function setUp() - { - if (!extension_loaded('bcmath') && !extension_loaded('gmp')) { - $this->markTestSkipped('Missing bcmath or gmp extensions'); - } - } - public function testFactoryCreatesBcmathAdapter() { if (!extension_loaded('bcmath')) { @@ -55,6 +44,9 @@ public function testFactoryCreatesGmpAdapter() public function testFactoryUsesDefaultAdapter() { + if (!extension_loaded('bcmath') && !extension_loaded('gmp')) { + $this->markTestSkipped('Missing bcmath or gmp extensions'); + } $this->assertTrue(BigInt::factory() instanceof AdapterInterface); } From 9805ea3800d9a3eabf7bdd89bec498c5f74e7433 Mon Sep 17 00:00:00 2001 From: Denis Portnov Date: Mon, 23 Jul 2012 20:28:08 +0400 Subject: [PATCH 2/2] removed tearDown() --- test/BigInteger/Adapter/AbstractTestCase.php | 47 ++++++++++++++++++++ test/BigInteger/Adapter/BcmathTest.php | 6 --- test/BigInteger/Adapter/GmpTest.php | 5 --- 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/test/BigInteger/Adapter/AbstractTestCase.php b/test/BigInteger/Adapter/AbstractTestCase.php index 43fce6f..0dbadf0 100644 --- a/test/BigInteger/Adapter/AbstractTestCase.php +++ b/test/BigInteger/Adapter/AbstractTestCase.php @@ -152,6 +152,11 @@ public function testDivisionByZeroRaisesException() $this->adapter->div('12345', '0'); } + /** + * Data provider for init() tests + * + * @return array + */ public function validInitProvider() { return array( @@ -173,6 +178,12 @@ public function validInitProvider() ); } + /** + * Data provider for init() tests + * Expects iit() to return false on these values + * + * @return array + */ public function invalidInitProvider() { return array( @@ -184,6 +195,12 @@ public function invalidInitProvider() ); } + /** + * Basic calculation data provider + * add, sub, mul, div, pow, mod + * + * @return array + */ public function basicCalcProvider() { return array( @@ -225,6 +242,11 @@ public function basicCalcProvider() ); } + /** + * Square root tests data provider + * + * @return array + */ public function sqrtProvider() { return array( @@ -234,6 +256,11 @@ public function sqrtProvider() ); } + /** + * Power modulus data provider + * + * @return array + */ public function powmodProvider() { return array( @@ -241,6 +268,11 @@ public function powmodProvider() ); } + /** + * abs() tests data provider + * + * @return array + */ public function absProvider() { return array( @@ -250,6 +282,11 @@ public function absProvider() ); } + /** + * Comparison function data provider + * + * @return array + */ public function comparisonProvider() { return array( @@ -262,6 +299,11 @@ public function comparisonProvider() ); } + /** + * Base conversion data provider + * + * @return array + */ public function baseConversionProvider() { return array( @@ -280,6 +322,11 @@ public function baseConversionProvider() ); } + /** + * binToInt() intToBin() tests provider + * + * @return array + */ public function binaryConversionProvider() { return array( diff --git a/test/BigInteger/Adapter/BcmathTest.php b/test/BigInteger/Adapter/BcmathTest.php index c0ea147..4dbddfd 100644 --- a/test/BigInteger/Adapter/BcmathTest.php +++ b/test/BigInteger/Adapter/BcmathTest.php @@ -30,14 +30,8 @@ public function setUp() $this->adapter = new Bcmath(); } - public function tearDown() - { - $this->adapter = null; - } - /** * Bcmath adapter test uses common test methods and data providers * inherited from abstract @see AbstractTestCase */ - } diff --git a/test/BigInteger/Adapter/GmpTest.php b/test/BigInteger/Adapter/GmpTest.php index a0e248b..79a1523 100644 --- a/test/BigInteger/Adapter/GmpTest.php +++ b/test/BigInteger/Adapter/GmpTest.php @@ -30,11 +30,6 @@ public function setUp() $this->adapter = new Gmp(); } - public function tearDown() - { - $this->adapter = null; - } - /** * Gmp adapter test uses common test methods and data providers * inherited from abstract @see AbstractTestCase