mirror of
https://github.com/10h30/wp-strava.git
synced 2026-06-05 15:10:01 +09:00
Added activity link tests
This commit is contained in:
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user