2015-06-25 17:00:29 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class FunctionsTest extends AnimeClient_TestCase {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Basic sanity test for _dir function
|
|
|
|
*/
|
|
|
|
public function testDir()
|
|
|
|
{
|
|
|
|
$this->assertEquals('foo'.DIRECTORY_SEPARATOR.'bar', _dir('foo', 'bar'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testIsSelected()
|
|
|
|
{
|
2015-06-26 12:03:42 -04:00
|
|
|
// Failure to match
|
|
|
|
$this->assertEquals('', is_selected('foo', 'bar'));
|
2015-06-25 17:00:29 -04:00
|
|
|
|
2015-06-26 12:03:42 -04:00
|
|
|
// Matches
|
|
|
|
$this->assertEquals('selected', is_selected('foo', 'foo'));
|
2015-06-25 17:00:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testIsNotSelected()
|
|
|
|
{
|
2015-06-26 12:03:42 -04:00
|
|
|
// Failure to match
|
|
|
|
$this->assertEquals('selected', is_not_selected('foo', 'bar'));
|
2015-06-25 17:00:29 -04:00
|
|
|
|
2015-06-26 12:03:42 -04:00
|
|
|
// Matches
|
|
|
|
$this->assertEquals('', is_not_selected('foo', 'foo'));
|
2015-06-25 17:00:29 -04:00
|
|
|
}
|
|
|
|
|
2015-06-26 12:03:42 -04:00
|
|
|
public function assetUrlProvider()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'single argument' => [
|
|
|
|
'config' => (object)[
|
|
|
|
'asset_path' => '//localhost/assets/'
|
|
|
|
],
|
|
|
|
'args' => [
|
|
|
|
'images'
|
|
|
|
],
|
|
|
|
'expected' => '//localhost/assets/images',
|
|
|
|
],
|
|
|
|
'multiple arguments' => [
|
|
|
|
'config' => (object)[
|
|
|
|
'asset_path' => '//localhost/assets/'
|
|
|
|
],
|
|
|
|
'args' => [
|
|
|
|
'images', 'anime', 'foo.png'
|
|
|
|
],
|
|
|
|
'expected' => '//localhost/assets/images/anime/foo.png'
|
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider assetUrlProvider
|
|
|
|
*/
|
|
|
|
public function testAssetUrl($config, $args, $expected)
|
|
|
|
{
|
|
|
|
global $config;
|
|
|
|
$config = func_get_arg(0);
|
|
|
|
|
|
|
|
$result = call_user_func_array('asset_url', $args);
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testIsLoggedIn()
|
|
|
|
{
|
|
|
|
$this->assertFalse(is_logged_in());
|
|
|
|
|
|
|
|
$_SESSION['hummingbird_anime_token'] = 'foobarbadsessionid';
|
|
|
|
|
|
|
|
$this->assertTrue(is_logged_in());
|
|
|
|
}
|
2015-06-25 17:00:29 -04:00
|
|
|
}
|