ソースを参照

Improving test coverage for CakePlugin

Jose Lorenzo Rodriguez 15 年 前
コミット
46d994c3f0
1 ファイル変更41 行追加0 行削除
  1. 41 0
      lib/Cake/tests/Case/Core/CakePluginTest.php

+ 41 - 0
lib/Cake/tests/Case/Core/CakePluginTest.php

@@ -140,6 +140,12 @@ class CakePluginTest extends CakeTestCase {
 		$this->assertEquals('loaded plugin bootstrap', Configure::read('CakePluginTest.test_plugin.bootstrap'));
 	}
 
+
+/**
+ * Tests that it is possible to load plugin bootstrap by calling a callback function
+ *
+ * @return void
+ */
 	public function testCallbackBootstrap() {
 		CakePlugin::load('TestPlugin', array('bootstrap' => array($this, 'pluginBootstrap')));
 		$expected = array('TestPlugin');
@@ -158,6 +164,41 @@ class CakePluginTest extends CakeTestCase {
 	}
 
 /**
+ * Tests that CakePlugin::load() throws an exception on unknown plugin
+ *
+ * @return void
+ * @expectedException MissingPluginException
+ */
+	public function testLoadNotFound() {
+		CakePlugin::load('MissingPlugin');
+	}
+
+
+/**
+ * Tests that CakePlugin::path() returns the correct path for the loaded plugins
+ *
+ * @return void
+ */
+	public function testPath() {
+		CakePlugin::load(array('TestPlugin', 'TestPluginTwo'));
+		$expected = CAKE_TESTS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS;
+		$this->assertEquals(CakePlugin::path('TestPlugin'), $expected);
+
+		$expected = CAKE_TESTS . 'test_app' . DS . 'plugins' . DS . 'test_plugin_two' . DS;
+		$this->assertEquals(CakePlugin::path('TestPluginTwo'), $expected);
+	}
+
+/**
+ * Tests that CakePlugin::path() throws an exception on unknown plugin
+ *
+ * @return void
+ * @expectedException MissingPluginException
+ */
+	public function testPathNotFound() {
+		CakePlugin::path('TestPlugin');
+	}
+
+/**
  * Auxiliary function to test plugin bootstrap callbacks
  *
  * @return void