Skip to content

Commit

Permalink
Add more coverage to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
acasademont committed Nov 21, 2017
1 parent 68231ef commit 6a951c8
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 127 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
composer.lock
vendor
.idea
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
</testsuites>

<filter>
<whitelist>
<directory>./tests/</directory>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
</phpunit>
Expand Down
31 changes: 4 additions & 27 deletions tests/CurrencyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,22 @@

use PHPUnit\Framework\TestCase;

/**
* @coversDefaultClass Money\Currency
* @uses Money\Currency
* @uses Money\Money
*/
final class CurrencyTest extends TestCase
{
/**
* @covers ::__construct
*/
public function testConstructor()
{
$currency = Currency::fromCode('EUR');

self::assertEquals('EUR', $currency->code());
}

/**
* @covers ::code
* @covers ::__toString
*/
public function testCode()
{
$currency = Currency::fromCode('EUR');
self::assertEquals('EUR', $currency->code());
self::assertEquals('EUR', (string) $currency);
}

/**
* @covers ::equals
*/
public function testDifferentInstancesAreEqual()
{
$c1 = Currency::fromCode('EUR');
Expand All @@ -54,39 +39,31 @@ public function testDifferentInstancesAreEqual()
self::assertTrue($c3->equals($c4));
}

/**
* @covers ::equals
*/
public function testDifferentCurrenciesAreNotEqual()
{
$c1 = Currency::fromCode('EUR');
$c2 = Currency::fromCode('USD');
self::assertFalse($c1->equals($c2));
}

/**
* @covers ::equals
*/
public function testToUpper()
{
$c1 = Currency::fromCode('EUR');
$c2 = Currency::fromCode('eur');
self::assertTrue($c1->equals($c2));
}

/**
* @expectedException Money\InvalidArgumentException
*/
public function testNonStringCode()
{
self::expectException(InvalidArgumentException::class);

Currency::fromCode(1234);
}

/**
* @expectedException Money\InvalidArgumentException
*/
public function testNon3LetterCode()
{
self::expectException(InvalidArgumentException::class);

Currency::fromCode('FooBar');
}
}
Loading

0 comments on commit 6a951c8

Please sign in to comment.