From bcbb24c0f5a36bf18506ae363cf195fd27924551 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Thu, 12 Mar 2020 12:04:20 -0400 Subject: [PATCH] Increase code coverage --- index.php | 6 ++++-- src/Ion/Friend.php | 2 ++ tests/Ion/FriendTest.php | 14 ++++++++------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/index.php b/index.php index 29c8539f..cef4c453 100644 --- a/index.php +++ b/index.php @@ -17,6 +17,8 @@ namespace Aviat\AnimeClient; use Aviat\AnimeClient\Types\Config as ConfigType; +use Whoops\Handler\PrettyPageHandler; +use Whoops\Run; use function Aviat\Ion\_dir; @@ -34,8 +36,8 @@ require_once __DIR__ . '/vendor/autoload.php'; // if (array_key_exists('ENV', $_ENV) && $_ENV['ENV'] === 'development') { - $whoops = new \Whoops\Run; - $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler); + $whoops = new Run; + $whoops->pushHandler(new PrettyPageHandler); $whoops->register(); } diff --git a/src/Ion/Friend.php b/src/Ion/Friend.php index 307eb448..675bbdc3 100644 --- a/src/Ion/Friend.php +++ b/src/Ion/Friend.php @@ -146,10 +146,12 @@ class Friend { } // Return NULL on any exception, so no further logic needed // in the catch block + // @codeCoverageIgnoreStart catch (\Exception $e) { return NULL; } + // @codeCoverageIgnoreEnd } } // End of Friend.php \ No newline at end of file diff --git a/tests/Ion/FriendTest.php b/tests/Ion/FriendTest.php index c71f6698..2fd12ca7 100644 --- a/tests/Ion/FriendTest.php +++ b/tests/Ion/FriendTest.php @@ -21,25 +21,27 @@ use Aviat\Ion\Tests\FriendTestClass; class FriendTest extends IonTestCase { + protected $friend; + public function setUp(): void { parent::setUp(); $obj = new FriendTestClass(); $this->friend = new Friend($obj); } - public function testPrivateMethod() + public function testPrivateMethod():void { $actual = $this->friend->getPrivate(); $this->assertEquals(23, $actual); } - public function testProtectedMethod() + public function testProtectedMethod():void { $actual = $this->friend->getProtected(); $this->assertEquals(4, $actual); } - public function testGet() + public function testGet():void { $this->assertEquals(356, $this->friend->protected); $this->assertNull($this->friend->foo); // Return NULL for non-existent properties @@ -48,7 +50,7 @@ class FriendTest extends IonTestCase { $this->assertNull($this->friend->parentPrivate); // Can't get a parent's privates } - public function testSet() + public function testSet(): void { $this->friend->private = 123; $this->assertEquals(123, $this->friend->private); @@ -57,7 +59,7 @@ class FriendTest extends IonTestCase { $this->assertNull($this->friend->foo); } - public function testBadInvokation() + public function testBadInvokation():void { $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage('Friend must be an object'); @@ -65,7 +67,7 @@ class FriendTest extends IonTestCase { $friend = new Friend('foo'); } - public function testBadMethod() + public function testBadMethod():void { $this->expectException('BadMethodCallException'); $this->expectExceptionMessage("Method 'foo' does not exist");