diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c9a5ddc..f282228 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,6 +51,7 @@ jobs: - name: "Install dependencies with Composer" uses: "ramsey/composer-install@v2" + - name: "Run PHPUnit" run: "vendor/bin/phpunit" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index eb3b4bf..812ee72 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -5,9 +5,9 @@ beStrictAboutOutputDuringTests="true" bootstrap="vendor/autoload.php" colors="true" - convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" + convertErrorsToExceptions="false" + convertNoticesToExceptions="false" + convertWarningsToExceptions="false" failOnRisky="true" failOnWarning="true" processIsolation="false" diff --git a/src/Rates.php b/src/Rates.php index 779cb7a..cbbc3ce 100644 --- a/src/Rates.php +++ b/src/Rates.php @@ -75,9 +75,11 @@ private function loadFromFile() ] ]); - if (is_array($data)) { - $this->rates = $data; + if (false === is_array($data)) { + throw new Exception("Unserializable file content"); } + + $this->rates = $data; } private function loadFromRemote() diff --git a/tests/RatesTest.php b/tests/RatesTest.php index 306db6d..78b62f2 100644 --- a/tests/RatesTest.php +++ b/tests/RatesTest.php @@ -86,7 +86,7 @@ public function testRatesAreLoadedFromFile() // test by invalidating file and testing for exception file_put_contents('vendor/rates', 'foobar'); $rates = new Rates('vendor/rates', 30, $client); - $this->expectError(Error::class); + $this->expectException(Exception::class); $this->assertEquals(21.0, $rates->getRateForCountry('NL')); }