Added activity link tests

This commit is contained in:
Justin Foell
2020-06-26 14:54:44 -05:00
parent ffd7762f43
commit f119ccf360
+54
View File
@@ -54,4 +54,58 @@ class WPStrava_ActivityTest extends TestCase {
$actual = $this->activity->get_activities_longer_than( $this->activities, '10' );
$this->assertEquals( $expected, $actual );
}
/**
* Test that links with a title are rendered correctly.
*
* @author Justin Foell <justin@foell.org>
* @since 2.3.2
*/
public function test_activity_link_with_title() {
$activity_name = 'Chill Day';
$activity_id = 123456778928065;
$expected = "<a href='" . WPStrava_Activity::ACTIVITIES_URL . $activity_id . "' title='{$activity_name}'>{$activity_name}</a>";
$actual = $this->activity->get_activity_link( $activity_id, $activity_name, $activity_name );
$this->assertEquals( $expected, $actual );
}
/**
* Test that links with no title are rendered correctly.
*
* @author Justin Foell <justin@foell.org>
* @since 2.3.2
*/
public function test_activity_link_no_title() {
$activity_name = 'Chill Day';
$activity_id = 123456778928065;
$expected = "<a href='" . WPStrava_Activity::ACTIVITIES_URL . $activity_id . "'>{$activity_name}</a>";
$actual = $this->activity->get_activity_link( $activity_id, $activity_name );
$this->assertEquals( $expected, $actual );
}
/**
* Test that links with no_link set just render the supplied text.
*
* @author Justin Foell <justin@foell.org>
* @since 2.3.2
*/
public function test_activity_no_link() {
\WP_Mock::userFunction(
'get_option',
array(
'args' => 'strava_no_link',
'times' => 1,
'return' => true,
)
);
$activity_name = 'Afternoon Ride';
$actual = $this->activity->get_activity_link( 123456778928065, 'Afternoon Ride' );
$this->assertEquals( $activity_name, $actual );
}
}