diff --git a/src/Yasumi/Yasumi.php b/src/Yasumi/Yasumi.php index 6616fe68a..6e39b5c5a 100755 --- a/src/Yasumi/Yasumi.php +++ b/src/Yasumi/Yasumi.php @@ -72,7 +72,7 @@ public static function create($class, $year = null, $locale = self::DEFAULT_LOCA { // Find and return holiday provider instance $providerClass = sprintf('Yasumi\Provider\%s', str_replace('/', '\\', $class)); - if (!class_exists($providerClass)) { + if (!class_exists($providerClass) || $class === 'AbstractProvider') { throw new InvalidArgumentException(sprintf('Unable to find holiday provider "%s".', $class)); } diff --git a/tests/Base/YasumiTest.php b/tests/Base/YasumiTest.php index f9826a05d..9d1f7929b 100644 --- a/tests/Base/YasumiTest.php +++ b/tests/Base/YasumiTest.php @@ -43,6 +43,26 @@ public function testCreateWithInvalidProvider() Yasumi::create('Mars'); } + /** + * Tests that an InvalidArgumentException is thrown in case we try to load a Trait as provider. + * + * @expectedException InvalidArgumentException + */ + public function testCreateWithInvalidProviderBecauseItsATrait() + { + Yasumi::create('CommonHolidays'); + } + + /** + * Tests that an InvalidArgumentException is thrown in case we try to load the AbstractProvider as provider. + * + * @expectedException InvalidArgumentException + */ + public function testCreateWithAbstractClassProvider() + { + Yasumi::create('AbstractProvider'); + } + /** * Tests that an Yasumi\Exception\UnknownLocaleException is thrown in case an invalid locale is given. *