Skip to content

Commit

Permalink
Improve phpunit config and code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
sagikazarmark committed Jan 16, 2016
1 parent e62c607 commit 976ecd3
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 129 deletions.
13 changes: 4 additions & 9 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
strict="true"
colors="true"
verbose="true">
<phpunit colors="true" bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="money">
<directory suffix="Test.php">tests</directory>
<testsuite name="Money Test Suite">
<directory>tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<whitelist>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
Expand Down
2 changes: 1 addition & 1 deletion tests/BcMathCalculatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Money\Calculator\BcMathCalculator;
use Money\Money;

class BcMathCalculatorTest extends \PHPUnit_Framework_TestCase
final class BcMathCalculatorTest extends \PHPUnit_Framework_TestCase
{
public function testCompare()
{
Expand Down
38 changes: 3 additions & 35 deletions tests/CurrencyPairTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,8 @@
use Money\CurrencyPair;
use Money\Money;

/**
* @coversDefaultClass Money\CurrencyPair
*
* @uses Money\Currency
* @uses Money\Money
* @uses Money\CurrencyPair
*/
final class CurrencyPairTest extends \PHPUnit_Framework_TestCase
{
/**
* @covers ::__construct
*/
public function testConstructor()
{
$eur = new Currency('EUR');
Expand All @@ -32,19 +22,15 @@ public function testConstructor()
}

/**
* @covers ::__construct
* @dataProvider provideNonNumericRatio
* @expectedException InvalidArgumentException
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Conversion ratio must be numeric
*/
public function testConstructorWithNonNumericRatio($nonNumericRatio)
{
new CurrencyPair(new Currency('EUR'), new Currency('USD'), $nonNumericRatio);
}

/**
* @covers ::getConversionRatio
*/
public function testGetRatio()
{
$ratio = 1.2500;
Expand All @@ -53,19 +39,13 @@ public function testGetRatio()
$this->assertEquals($ratio, $pair->getConversionRatio());
}

/**
* @covers ::getBaseCurrency
*/
public function testGetBaseCurrency()
{
$pair = new CurrencyPair(new Currency('EUR'), new Currency('USD'), 1.2500);

$this->assertEquals(new Currency('EUR'), $pair->getBaseCurrency());
}

/**
* @covers ::getCounterCurrency
*/
public function testGetCounterCurrency()
{
$pair = new CurrencyPair(new Currency('EUR'), new Currency('USD'), 1.2500);
Expand All @@ -74,8 +54,7 @@ public function testGetCounterCurrency()
}

/**
* @covers ::convert
* @expectedException InvalidArgumentException
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The Money has the wrong currency
*/
public function testConvertWithInvalidCurrency()
Expand All @@ -86,9 +65,6 @@ public function testConvertWithInvalidCurrency()
$pair->convert($money);
}

/**
* @covers ::convert
*/
public function testConvertsEurToUsdAndBack()
{
$eur = Money::EUR(100);
Expand All @@ -102,9 +78,6 @@ public function testConvertsEurToUsdAndBack()
$this->assertEquals(Money::EUR(100), $eur);
}

/**
* @covers ::convert
*/
public function testConvertsEurToUsdWithModes()
{
$eur = Money::EUR(10);
Expand All @@ -119,17 +92,13 @@ public function testConvertsEurToUsdWithModes()
}

/**
* @covers ::equals
* @dataProvider provideEqualityComparisonPairs
*/
public function testEqualityComparisons($pair1, $pair2, $equal)
{
$this->assertSame($equal, $pair1->equals($pair2));
}

/**
* @covers ::createFromIso
*/
public function testParsesIso()
{
$pair = CurrencyPair::createFromIso('EUR/USD 1.2500');
Expand All @@ -138,8 +107,7 @@ public function testParsesIso()
}

/**
* @covers ::createFromIso
* @expectedException InvalidArgumentException
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Can't create currency pair from ISO string '1.2500', format of string is invalid
*/
public function testParsesIsoWithException()
Expand Down
20 changes: 0 additions & 20 deletions tests/CurrencyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
use Money\Currency;
use Prophecy\Argument;

/**
* @coversDefaultClass Money\Currency
*
* @uses Money\Currency
* @uses Money\Money
* @uses Money\CurrencyPair
*/
final class CurrencyTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
Expand All @@ -22,38 +15,25 @@ public function setUp()
$this->usd2 = new Currency('USD');
}

/**
* @covers ::__construct
*/
public function testConstructor()
{
$currency = new Currency('EUR');

$this->assertEquals('EUR', $currency->getCode());
}

/**
* @covers ::getCode
* @covers ::__toString
*/
public function testCode()
{
$this->assertEquals('EUR', $this->euro1->getCode());
$this->assertEquals('EUR', (string) $this->euro1);
}

/**
* @covers ::equals
*/
public function testDifferentInstancesAreEqual()
{
$this->assertTrue($this->euro1->equals($this->euro2));
$this->assertTrue($this->usd1->equals($this->usd2));
}

/**
* @covers ::equals
*/
public function testDifferentCurrenciesAreNotEqual()
{
$this->assertFalse($this->euro1->equals($this->usd1));
Expand Down
2 changes: 1 addition & 1 deletion tests/GmpCalculatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Money\Calculator\GmpCalculator;
use Money\Money;

class GmpCalculatorTest extends \PHPUnit_Framework_TestCase
final class GmpCalculatorTest extends \PHPUnit_Framework_TestCase
{
public function testCompare()
{
Expand Down
9 changes: 0 additions & 9 deletions tests/ISOCurrenciesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,8 @@
use Money\Currency;
use Money\ISOCurrencies;

/**
* @coversDefaultClass Money\ISOCurrencies
*
* @uses Money\Currency
*/
final class ISOCurrenciesTest extends \PHPUnit_Framework_TestCase
{
/**
* @covers ::__construct
* @covers ::contains
*/
public function testConstructor()
{
$currencies = new ISOCurrencies();
Expand Down
2 changes: 1 addition & 1 deletion tests/MoneyFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Money\IntlMoneyFormatter;
use Money\Money;

class MoneyFormatterTest extends \PHPUnit_Framework_TestCase
final class MoneyFormatterTest extends \PHPUnit_Framework_TestCase
{
public function testRoundMoney()
{
Expand Down
Loading

0 comments on commit 976ecd3

Please sign in to comment.