Added System of Measure (English) unit tests;

Fixed a bug in pace formatting
This commit is contained in:
Justin Foell
2019-03-01 11:41:41 -06:00
parent cf1af2a0b2
commit c5fdb24244
6 changed files with 104 additions and 31 deletions
+3
View File
@@ -1,5 +1,8 @@
# Unit Tests
While the main WP-Strava plugin code itself is PHP 5.2 compatible, you will need at least PHP 7.2 to run unit tests.
## Installation
In the main plugin directory run the following commands from the terminal:
+63 -3
View File
@@ -4,8 +4,68 @@ use \WP_Mock\Tools\TestCase;
class WPStrava_SOMEnglishTest extends TestCase {
public function test_true() {
$som = new WPStrava_SOMEnglish();
$this->assertInstanceOf( 'WPStrava_SOMEnglish', $som );
private $som;
public function setUp() : void {
$this->som = new WPStrava_SOMEnglish();
}
public function test_object() {
$this->assertInstanceOf( 'WPStrava_SOMEnglish', $this->som );
}
/**
* Test that 10,000 meters is 6.21 miles using both string and float inputs.
*
* @author Justin Foell <justin.foell@webdevstudios.com>
* @since NEXT
*/
public function test_distance() {
$this->assertEquals( '6.21' , $this->som->distance( '10000' ) );
$this->assertEquals( '6.21' , $this->som->distance( 10000 ) );
}
/**
* Test that 6.213712 miles is 10,000.00 meters using both string and float inputs.
*
* @author Justin Foell <justin.foell@webdevstudios.com>
* @since NEXT
*/
public function test_distance_inverse() {
$this->assertEquals( '10,000.00' , $this->som->distance_inverse( '6.213712' ) );
$this->assertEquals( '10,000.00' , $this->som->distance_inverse( 6.213712 ) );
}
/**
* Test that 6.705 meters per second is 15.00 mph using both string and float inputs.
*
* @author Justin Foell <justin.foell@webdevstudios.com>
* @since NEXT
*/
public function test_speed() {
$this->assertEquals( '15.00', $this->som->speed( '6.705' ) );
$this->assertEquals( '15.00', $this->som->speed( 6.705 ) );
}
/**
* Test that 2.68224 meters per second is a 10:00 minute/mile pace using both string and float inputs.
*
* @author Justin Foell <justin.foell@webdevstudios.com>
* @since NEXT
*/
public function test_pace() {
$this->assertEquals( '10:00', $this->som->pace( '2.68224' ) );
$this->assertEquals( '10:00', $this->som->pace( 2.68224 ) );
}
/**
* Test that 60.96 meters is 200.00 feet using both string and float inputs.
*
* @author Justin Foell <justin.foell@webdevstudios.com>
* @since NEXT
*/
public function test_elevation() {
$this->assertEquals( '200.00', $this->som->elevation( '60.96' ) );
$this->assertEquals( '200.00', $this->som->elevation( 60.96 ) );
}
}