-
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.
- Loading branch information
Showing
5 changed files
with
218 additions
and
0 deletions.
There are no files selected for viewing
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
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,37 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
/** | ||
* This file is part of the jordanbrauer/unit-converter PHP package. | ||
* | ||
* @copyright 2018 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. | ||
*/ | ||
|
||
namespace UnitConverter\Unit\Pressure; | ||
|
||
/** | ||
* Kilopascal unit data class. | ||
* | ||
* @version 1.0.0 | ||
* @since 0.8.5 | ||
* @author Michal Podsednik | ||
*/ | ||
class Hectopascal extends PressureUnit | ||
{ | ||
protected function configure(): void | ||
{ | ||
$this | ||
->setName("hectopascal") | ||
|
||
->setSymbol("hPa") | ||
|
||
->setScientificSymbol("hPa") | ||
|
||
->setUnits(100); | ||
} | ||
} |
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,37 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
/** | ||
* This file is part of the jordanbrauer/unit-converter PHP package. | ||
* | ||
* @copyright 2018 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. | ||
*/ | ||
|
||
namespace UnitConverter\Unit\Pressure; | ||
|
||
/** | ||
* Inches of mercury unit data class. | ||
* | ||
* @version 1.0.0 | ||
* @since 0.8.5 | ||
* @author Michal Podsednik | ||
*/ | ||
class InchesOfMercury extends PressureUnit | ||
{ | ||
protected function configure(): void | ||
{ | ||
$this | ||
->setName("inches of mercury") | ||
|
||
->setSymbol("inHg") | ||
|
||
->setScientificSymbol("inHg") | ||
|
||
->setUnits(3386.38867); | ||
} | ||
} |
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,70 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
/** | ||
* This file is part of the jordanbrauer/unit-converter PHP package. | ||
* | ||
* @copyright 2018 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. | ||
*/ | ||
|
||
namespace UnitConverter\Tests\Integration\Unit\Pressure; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use UnitConverter\Calculator\SimpleCalculator; | ||
use UnitConverter\Registry\UnitRegistry; | ||
use UnitConverter\Unit\Pressure\Hectopascal; | ||
use UnitConverter\Unit\Pressure\Pascal; | ||
use UnitConverter\UnitConverter; | ||
|
||
/** | ||
* Test that a hectopascal is indeed a hectoascal. | ||
* | ||
* @covers UnitConverter\Unit\Pressure\Hectopascal | ||
* @uses UnitConverter\Unit\Pressure\Pascal | ||
* @uses UnitConverter\Unit\AbstractUnit | ||
* @uses UnitConverter\UnitConverter | ||
* @uses UnitConverter\Calculator\SimpleCalculator | ||
* @uses UnitConverter\Calculator\AbstractCalculator | ||
* @uses UnitConverter\Calculator\Formula\AbstractFormula | ||
* @uses UnitConverter\Calculator\Formula\UnitConversionFormula | ||
* @uses UnitConverter\Registry\UnitRegistry | ||
* @uses UnitConverter\Support\ArrayDotNotation | ||
* @uses UnitConverter\Support\Collection | ||
*/ | ||
class HectopascalSpec extends TestCase | ||
{ | ||
protected function setUp() | ||
{ | ||
$this->converter = new UnitConverter( | ||
new UnitRegistry([ | ||
new Pascal(), | ||
new Hectopascal(), | ||
]), | ||
new SimpleCalculator() | ||
); | ||
} | ||
|
||
protected function tearDown() | ||
{ | ||
unset($this->converter); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function assert1HectopascalIs100Pascal() | ||
{ | ||
$expected = 100; | ||
$actual = $this->converter | ||
->convert(1) | ||
->from("hPa") | ||
->to("Pa"); | ||
|
||
$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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
/** | ||
* This file is part of the jordanbrauer/unit-converter PHP package. | ||
* | ||
* @copyright 2018 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. | ||
*/ | ||
|
||
namespace UnitConverter\Tests\Integration\Unit\Pressure; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use UnitConverter\Calculator\SimpleCalculator; | ||
use UnitConverter\Registry\UnitRegistry; | ||
use UnitConverter\Unit\Pressure\InchesOfMercury; | ||
use UnitConverter\Unit\Pressure\Pascal; | ||
use UnitConverter\UnitConverter; | ||
|
||
/** | ||
* Test that an one inch of mercury is indeed a pound-force per sq in. | ||
* | ||
* @covers UnitConverter\Unit\Pressure\PoundForcePerSquareInch | ||
* @uses UnitConverter\Unit\Pressure\Pascal | ||
* @uses UnitConverter\Unit\AbstractUnit | ||
* @uses UnitConverter\UnitConverter | ||
* @uses UnitConverter\Calculator\SimpleCalculator | ||
* @uses UnitConverter\Calculator\AbstractCalculator | ||
* @uses UnitConverter\Calculator\Formula\AbstractFormula | ||
* @uses UnitConverter\Calculator\Formula\UnitConversionFormula | ||
* @uses UnitConverter\Registry\UnitRegistry | ||
* @uses UnitConverter\Support\ArrayDotNotation | ||
* @uses UnitConverter\Support\Collection | ||
*/ | ||
class InchesOfMercurySpec extends TestCase | ||
{ | ||
protected function setUp() | ||
{ | ||
$this->converter = new UnitConverter( | ||
new UnitRegistry([ | ||
new Pascal(), | ||
new InchesOfMercury(), | ||
]), | ||
new SimpleCalculator() | ||
); | ||
} | ||
|
||
protected function tearDown() | ||
{ | ||
unset($this->converter); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function assert1InchOfMercuryIs338638867Pascals() | ||
{ | ||
$expected = 3386.38867; | ||
$actual = $this->converter | ||
->convert(1) | ||
->from("inHg") | ||
->to("Pa"); | ||
|
||
$this->assertEquals($expected, $actual); | ||
} | ||
} |