2020-03-11 23:04:01 -04:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
/**
|
2020-03-12 11:45:11 -04:00
|
|
|
* Hummingbird Anime List Client
|
2020-03-11 23:04:01 -04:00
|
|
|
*
|
2020-03-12 11:45:11 -04:00
|
|
|
* An API client for Kitsu to manage anime and manga watch lists
|
2020-03-11 23:04:01 -04:00
|
|
|
*
|
2020-04-10 15:39:39 -04:00
|
|
|
* PHP version 7.4
|
2020-03-11 23:04:01 -04:00
|
|
|
*
|
2020-03-12 11:45:11 -04:00
|
|
|
* @package HummingbirdAnimeClient
|
2020-03-11 23:04:01 -04:00
|
|
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
2020-03-12 11:45:11 -04:00
|
|
|
* @copyright 2015 - 2020 Timothy J. Warren
|
2020-03-11 23:04:01 -04:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
2020-08-04 09:30:21 -04:00
|
|
|
* @version 5.1
|
2020-03-12 11:45:11 -04:00
|
|
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
2020-03-11 23:04:01 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Aviat\Ion\Tests;
|
|
|
|
|
|
|
|
use Aviat\Ion\Friend;
|
|
|
|
use Aviat\Ion\Tests\FriendTestClass;
|
|
|
|
|
2020-03-12 09:52:45 -04:00
|
|
|
class FriendTest extends IonTestCase {
|
2020-03-11 23:04:01 -04:00
|
|
|
|
2020-03-12 12:04:20 -04:00
|
|
|
protected $friend;
|
|
|
|
|
2020-03-11 23:04:01 -04:00
|
|
|
public function setUp(): void {
|
|
|
|
parent::setUp();
|
|
|
|
$obj = new FriendTestClass();
|
|
|
|
$this->friend = new Friend($obj);
|
|
|
|
}
|
|
|
|
|
2020-03-12 12:04:20 -04:00
|
|
|
public function testPrivateMethod():void
|
2020-03-11 23:04:01 -04:00
|
|
|
{
|
|
|
|
$actual = $this->friend->getPrivate();
|
|
|
|
$this->assertEquals(23, $actual);
|
|
|
|
}
|
|
|
|
|
2020-03-12 12:04:20 -04:00
|
|
|
public function testProtectedMethod():void
|
2020-03-11 23:04:01 -04:00
|
|
|
{
|
|
|
|
$actual = $this->friend->getProtected();
|
|
|
|
$this->assertEquals(4, $actual);
|
|
|
|
}
|
|
|
|
|
2020-03-12 12:04:20 -04:00
|
|
|
public function testGet():void
|
2020-03-11 23:04:01 -04:00
|
|
|
{
|
|
|
|
$this->assertEquals(356, $this->friend->protected);
|
|
|
|
$this->assertNull($this->friend->foo); // Return NULL for non-existent properties
|
|
|
|
$this->assertEquals(47, $this->friend->parentProtected);
|
|
|
|
$this->assertEquals(84, $this->friend->grandParentProtected);
|
|
|
|
$this->assertNull($this->friend->parentPrivate); // Can't get a parent's privates
|
|
|
|
}
|
|
|
|
|
2020-03-12 12:04:20 -04:00
|
|
|
public function testSet(): void
|
2020-03-11 23:04:01 -04:00
|
|
|
{
|
|
|
|
$this->friend->private = 123;
|
|
|
|
$this->assertEquals(123, $this->friend->private);
|
|
|
|
|
|
|
|
$this->friend->foo = 32;
|
|
|
|
$this->assertNull($this->friend->foo);
|
|
|
|
}
|
|
|
|
|
2020-03-12 12:04:20 -04:00
|
|
|
public function testBadInvokation():void
|
2020-03-11 23:04:01 -04:00
|
|
|
{
|
|
|
|
$this->expectException('InvalidArgumentException');
|
|
|
|
$this->expectExceptionMessage('Friend must be an object');
|
|
|
|
|
|
|
|
$friend = new Friend('foo');
|
|
|
|
}
|
|
|
|
|
2020-03-12 12:04:20 -04:00
|
|
|
public function testBadMethod():void
|
2020-03-11 23:04:01 -04:00
|
|
|
{
|
|
|
|
$this->expectException('BadMethodCallException');
|
|
|
|
$this->expectExceptionMessage("Method 'foo' does not exist");
|
|
|
|
|
|
|
|
$this->friend->foo();
|
|
|
|
}
|
|
|
|
}
|