From 5dd3d6e2d3184a7bdf270963efcc8dd5e624df34 Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Sat, 24 Oct 2020 10:01:05 +0100 Subject: [PATCH] Increase coverage --- codecov.yml | 5 +++++ test/ApplicationTest.php | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 codecov.yml diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..25f3570d --- /dev/null +++ b/codecov.yml @@ -0,0 +1,5 @@ +coverage: + status: + patch: + default: + target: 70% diff --git a/test/ApplicationTest.php b/test/ApplicationTest.php index 1c9b0c98..42ad924b 100644 --- a/test/ApplicationTest.php +++ b/test/ApplicationTest.php @@ -6,6 +6,7 @@ use PhpSchool\PhpWorkshop\Application; use PHPUnit\Framework\TestCase; +use PhpSchool\PhpWorkshop\Exception\InvalidArgumentException; class ApplicationTest extends TestCase { @@ -58,4 +59,30 @@ public function testEventListenersFromLocalAndWorkshopConfigAreMerged(): void $eventListeners ); } + + public function testExceptionIsThrownIfConfigFileDoesNotExist(): void + { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('File "not-existing-file.php" was expected to exist.'); + + new Application('My workshop', 'not-existing-file.php'); + } + + public function testExceptionIsThrownIfResultClassDoesNotExist(): void + { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Class "NotExistingClass" does not exist'); + + $app = new Application('My workshop', __DIR__ . '/../app/config.php'); + $app->addResult(\NotExistingClass::class, \NotExistingClass::class); + } + + public function testExceptionIsThrownIfResultRendererClassDoesNotExist(): void + { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Class "NotExistingClass" does not exist'); + + $app = new Application('My workshop', __DIR__ . '/../app/config.php'); + $app->addResult(\PhpSchool\PhpWorkshop\Result\Success::class, \NotExistingClass::class); + } }