-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update: add missing integration tests for units of volume
- Loading branch information
1 parent
541f1d1
commit 8651ae6
Showing
5 changed files
with
279 additions
and
11 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
tests/integration/UnitConverter/Unit/Volume/CubicMetre.spec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the jordanbrauer/unit-converter PHP package. | ||
* | ||
* @copyright 2017 Jordan Brauer <[email protected]> | ||
* @license MIT | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare (strict_types = 1); | ||
|
||
namespace UnitConverter\Tests\Integration\Unit\Volume; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use UnitConverter\UnitConverter; | ||
use UnitConverter\Calculator\SimpleCalculator; | ||
use UnitConverter\Registry\UnitRegistry; | ||
use UnitConverter\Unit\Volume\Litre; | ||
use UnitConverter\Unit\Volume\CubicMetre; | ||
|
||
/** | ||
* Ensure that a cubic metre is a metre that has been cubed. | ||
* | ||
* @covers UnitConverter\Unit\Volume\CubicMetre | ||
* @uses UnitConverter\Unit\Volume\Litre | ||
* @uses UnitConverter\Unit\AbstractUnit | ||
* @uses UnitConverter\UnitConverter | ||
* @uses UnitConverter\Calculator\SimpleCalculator | ||
* @uses UnitConverter\Calculator\AbstractCalculator | ||
* @uses UnitConverter\Registry\UnitRegistry | ||
*/ | ||
class CubicMetreSpec extends TestCase | ||
{ | ||
protected function setUp () | ||
{ | ||
$this->converter = new UnitConverter( | ||
new UnitRegistry(array( | ||
new Litre, | ||
new CubicMetre, | ||
)), | ||
new SimpleCalculator | ||
); | ||
} | ||
|
||
protected function tearDown () | ||
{ | ||
unset($this->converter); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function assert1CubicMetreIs1000Litres () | ||
{ | ||
$expected = 1000; | ||
$actual = $this->converter | ||
->convert(1) | ||
->from("m3") | ||
->to("L") | ||
; | ||
|
||
$this->assertEquals($expected, $actual); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
tests/integration/UnitConverter/Unit/Volume/Gallon.spec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the jordanbrauer/unit-converter PHP package. | ||
* | ||
* @copyright 2017 Jordan Brauer <[email protected]> | ||
* @license MIT | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare (strict_types = 1); | ||
|
||
namespace UnitConverter\Tests\Integration\Unit\Volume; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use UnitConverter\UnitConverter; | ||
use UnitConverter\Calculator\SimpleCalculator; | ||
use UnitConverter\Registry\UnitRegistry; | ||
use UnitConverter\Unit\Volume\Litre; | ||
use UnitConverter\Unit\Volume\Gallon; | ||
|
||
/** | ||
* Ensure that a U.S. gallon is a U.S. gallon. | ||
* | ||
* @covers UnitConverter\Unit\Volume\Gallon | ||
* @uses UnitConverter\Unit\Volume\Litre | ||
* @uses UnitConverter\Unit\AbstractUnit | ||
* @uses UnitConverter\UnitConverter | ||
* @uses UnitConverter\Calculator\SimpleCalculator | ||
* @uses UnitConverter\Calculator\AbstractCalculator | ||
* @uses UnitConverter\Registry\UnitRegistry | ||
*/ | ||
class GallonSpec extends TestCase | ||
{ | ||
protected function setUp () | ||
{ | ||
$this->converter = new UnitConverter( | ||
new UnitRegistry(array( | ||
new Litre, | ||
new Gallon, | ||
)), | ||
new SimpleCalculator | ||
); | ||
} | ||
|
||
protected function tearDown () | ||
{ | ||
unset($this->converter); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function assert1GallonIs3decimal78541Litres () | ||
{ | ||
$expected = 3.78541; | ||
$actual = $this->converter | ||
->convert(1, 5) | ||
->from("gal") | ||
->to("L") | ||
; | ||
|
||
$this->assertEquals($expected, $actual); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
tests/integration/UnitConverter/Unit/Volume/Litre.spec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the jordanbrauer/unit-converter PHP package. | ||
* | ||
* @copyright 2017 Jordan Brauer <[email protected]> | ||
* @license MIT | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare (strict_types = 1); | ||
|
||
namespace UnitConverter\Tests\Integration\Unit\Volume; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use UnitConverter\UnitConverter; | ||
use UnitConverter\Calculator\SimpleCalculator; | ||
use UnitConverter\Registry\UnitRegistry; | ||
use UnitConverter\Unit\Volume\Litre; | ||
|
||
/** | ||
* Ensure that a litre is litre. | ||
* | ||
* @covers UnitConverter\Unit\Volume\Litre | ||
* @uses UnitConverter\Unit\AbstractUnit | ||
* @uses UnitConverter\UnitConverter | ||
* @uses UnitConverter\Calculator\SimpleCalculator | ||
* @uses UnitConverter\Calculator\AbstractCalculator | ||
* @uses UnitConverter\Registry\UnitRegistry | ||
*/ | ||
class LitreSpec extends TestCase | ||
{ | ||
protected function setUp () | ||
{ | ||
$this->converter = new UnitConverter( | ||
new UnitRegistry(array( | ||
new Litre, | ||
)), | ||
new SimpleCalculator | ||
); | ||
} | ||
|
||
protected function tearDown () | ||
{ | ||
unset($this->converter); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function assert1LitreIs1Litre () | ||
{ | ||
$expected = 1; | ||
$actual = $this->converter | ||
->convert(1) | ||
->from("L") | ||
->to("L") | ||
; | ||
|
||
$this->assertEquals($expected, $actual); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
tests/integration/UnitConverter/Unit/Volume/Millilitre.spec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the jordanbrauer/unit-converter PHP package. | ||
* | ||
* @copyright 2017 Jordan Brauer <[email protected]> | ||
* @license MIT | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare (strict_types = 1); | ||
|
||
namespace UnitConverter\Tests\Integration\Unit\Volume; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use UnitConverter\UnitConverter; | ||
use UnitConverter\Calculator\SimpleCalculator; | ||
use UnitConverter\Registry\UnitRegistry; | ||
use UnitConverter\Unit\Volume\Litre; | ||
use UnitConverter\Unit\Volume\Millilitre; | ||
|
||
/** | ||
* Ensure that a millilitre is a millilitre. | ||
* | ||
* @covers UnitConverter\Unit\Volume\Millilitre | ||
* @uses UnitConverter\Unit\Volume\Litre | ||
* @uses UnitConverter\Unit\AbstractUnit | ||
* @uses UnitConverter\UnitConverter | ||
* @uses UnitConverter\Calculator\SimpleCalculator | ||
* @uses UnitConverter\Calculator\AbstractCalculator | ||
* @uses UnitConverter\Registry\UnitRegistry | ||
*/ | ||
class MillilitreSpec extends TestCase | ||
{ | ||
protected function setUp () | ||
{ | ||
$this->converter = new UnitConverter( | ||
new UnitRegistry(array( | ||
new Litre, | ||
new Millilitre, | ||
)), | ||
new SimpleCalculator | ||
); | ||
} | ||
|
||
protected function tearDown () | ||
{ | ||
unset($this->converter); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function assert1MillilitreIs0decimal001Litres () | ||
{ | ||
$expected = 0.001; | ||
$actual = $this->converter | ||
->convert(1, 3) | ||
->from("mL") | ||
->to("L") | ||
; | ||
|
||
$this->assertEquals($expected, $actual); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters