Permalink
Browse files

Separated UnsupportedException to individual file and added Unsupport…

…edExceptionTest

Signed-off-by: Darren Hill <dchill42@gmail.com>
  • Loading branch information...
1 parent cddaade commit 23eb60931c43ea9d17a26c75be3a2229d71abdf4 @dchill42 dchill42 committed Feb 27, 2014
Showing with 117 additions and 36 deletions.
  1. +0 −36 system/core/Loader.php
  2. +67 −0 system/core/UnsupportedException.php
  3. +50 −0 tests/Xylophone/core/UnsupportedExceptionTest.php
View
@@ -29,42 +29,6 @@
defined('BASEPATH') OR exit('No direct script access allowed');
-/**
- * Resource Unsupported Exception
- *
- * This exception may be thrown from the constructor of any class which deems
- * itself unsupported by the environment. The class may specify an alternate
- * class to try loading in place of itself. The exception is mainly intended
- * for drivers such as Cache to swap out a different driver when the configured
- * one won't work.
- *
- * Loader will catch this exception and check for an alternate class, which it
- * will try to load instead. There is a hard limit of 5 attempts at loading a
- * class before Loader will quit trying, regardless of further exceptions, to
- * prevent infinite looping.
- *
- * @package Xylophone
- * @subpackage core
- */
-class UnsupportedException extends \Exception
-{
- /** @var string Alternate class to load */
- public $alternate = '';
-
- /**
- * Constructor
- *
- * @param string $alternate Alternate class name
- * @return void
- */
- public function __construct($alternate = '')
- {
- // Call parent ctor and set alternate
- parent::__construct();
- $this->alternate = $alternate;
- }
-}
-
/**
* Loader Class
*
@@ -0,0 +1,67 @@
+<?php
+/**
+ * Xylophone
+ *
+ * An open source HMVC application development framework for PHP 5.3 or newer
+ * Derived from CodeIgniter, Copyright (c) 2008 - 2013, EllisLab, Inc. (http://ellislab.com/)
+ *
+ * NOTICE OF LICENSE
+ *
+ * Licensed under the Open Software License version 3.0
+ *
+ * This source file is subject to the Open Software License (OSL 3.0) that is
+ * bundled with this package in the files license.txt / license.rst. It is
+ * also available through the world wide web at this URL:
+ * http://opensource.org/licenses/OSL-3.0
+ * If you did not receive a copy of the license and are unable to obtain it
+ * through the world wide web, please send an email to licensing@xylophone.io
+ * so we can send you a copy immediately.
+ *
+ * @package Xylophone
+ * @author Xylophone Dev Team, EllisLab Dev Team
+ * @copyright Copyright (c) 2014, Xylophone Team (http://xylophone.io/)
+ * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ * @link http://xylophone.io
+ * @since Version 1.0
+ * @filesource
+ */
+namespace Xylophone\core;
+
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+/**
+ * Resource Unsupported Exception
+ *
+ * This exception may be thrown from the constructor of any class which deems
+ * itself unsupported by the environment. The class may specify an alternate
+ * class to try loading in place of itself. The exception is mainly intended
+ * for drivers such as Cache to swap out a different driver when the configured
+ * one won't work.
+ *
+ * Loader will catch this exception and check for an alternate class, which it
+ * will try to load instead. There is a hard limit of 5 attempts at loading a
+ * class before Loader will quit trying, regardless of further exceptions, to
+ * prevent infinite looping.
+ *
+ * @package Xylophone
+ * @subpackage core
+ */
+class UnsupportedException extends \Exception
+{
+ /** @var string Alternate class to load */
+ public $alternate = '';
+
+ /**
+ * Constructor
+ *
+ * @param string $alternate Alternate class name
+ * @return void
+ */
+ public function __construct($alternate = '')
+ {
+ // Call parent ctor and set alternate
+ parent::__construct();
+ $this->alternate = $alternate;
+ }
+}
+
@@ -0,0 +1,50 @@
+<?php
+/**
+ * Xylophone
+ *
+ * An open source HMVC application development framework for PHP 5.3 or newer
+ * Derived from CodeIgniter, Copyright (c) 2008 - 2013, EllisLab, Inc. (http://ellislab.com/)
+ *
+ * NOTICE OF LICENSE
+ *
+ * Licensed under the Open Software License version 3.0
+ *
+ * This source file is subject to the Open Software License (OSL 3.0) that is
+ * bundled with this package in the files license.txt / license.rst. It is
+ * also available through the world wide web at this URL:
+ * http://opensource.org/licenses/OSL-3.0
+ * If you did not receive a copy of the license and are unable to obtain it
+ * through the world wide web, please send an email to licensing@xylophone.io
+ * so we can send you a copy immediately.
+ *
+ * @package Xylophone
+ * @author Xylophone Dev Team, EllisLab Dev Team
+ * @copyright Copyright (c) 2014, Xylophone Team (http://xylophone.io/)
+ * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ * @link http://xylophone.io
+ * @since Version 1.0
+ * @filesource
+ */
+
+/**
+ * UnsupportedException Unit Test
+ *
+ * @package Xylophone
+ */
+class UnsupportedExceptionTest extends XyTestCase
+{
+ /**
+ * Test __construct()
+ */
+ public function testConstruct()
+ {
+ // Mock UnsupportedException
+ $ex = $this->getMock('Xylophone\core\UnsupportedException', null, array(), '', false);
+
+ // Set up arg, call __construct() and verify result
+ $alt = 'OtherClass';
+ $ex->__construct($alt);
+ $this->assertEquals($alt, $ex->alternate);
+ }
+}
+

0 comments on commit 23eb609

Please sign in to comment.