HummingBirdAnimeClient/tests/UtilTest.php

81 lines
1.4 KiB
PHP
Raw Normal View History

2016-08-29 17:09:56 -04:00
<?php
namespace Aviat\AnimeClient\Tests;
use Aviat\AnimeClient\Util;
2017-02-15 16:40:18 -05:00
class UtilTest extends AnimeClientTestCase {
2016-08-29 17:09:56 -04:00
public function setUp()
{
parent::setUp();
$this->util = new Util($this->container);
}
public function testIsSelected()
{
// Failure to match
$this->assertEquals('', Util::is_selected('foo', 'bar'));
// Matches
$this->assertEquals('selected', Util::is_selected('foo', 'foo'));
}
public function testIsNotSelected()
{
// Failure to match
$this->assertEquals('selected', Util::is_not_selected('foo', 'bar'));
// Matches
$this->assertEquals('', Util::is_not_selected('foo', 'foo'));
}
public function dataIsViewPage()
{
return [
[
'uri' => '/anime/update',
'expected' => FALSE
],
[
'uri' => '/anime/watching',
'expected' => TRUE
],
[
'uri' => '/manga/reading',
'expected' => TRUE
],
[
'uri' => '/manga/update',
'expected' => FALSE
]
];
}
/**
* @dataProvider dataIsViewPage
*/
public function testIsViewPage($uri, $expected)
{
$this->setSuperGlobals([
'_SERVER' => [
'REQUEST_URI' => $uri
]
]);
$this->assertEquals($expected, $this->util->is_view_page());
}
/**
* @dataProvider dataIsViewPage
*/
public function testIsFormPage($uri, $expected)
{
$this->setSuperGlobals([
'_SERVER' => [
'REQUEST_URI' => $uri
]
]);
$this->assertEquals(!$expected, $this->util->is_form_page());
}
}