|
|
@@ -0,0 +1,116 @@
|
|
|
+<?php
|
|
|
+/**
|
|
|
+ * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
|
|
+ * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
|
|
+ *
|
|
|
+ * Licensed under The MIT License
|
|
|
+ * For full copyright and license information, please see the LICENSE.txt
|
|
|
+ * Redistributions of files must retain the above copyright notice.
|
|
|
+ *
|
|
|
+ * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
|
|
+ * @link http://cakephp.org CakePHP(tm) Project
|
|
|
+ * @since CakePHP(tm) v3.0
|
|
|
+ * @license http://www.opensource.org/licenses/mit-license.php MIT License
|
|
|
+ */
|
|
|
+namespace Cake\Test\TestCase\View\Input;
|
|
|
+
|
|
|
+use Cake\TestSuite\TestCase;
|
|
|
+use Cake\View\Input\InputRegistry;
|
|
|
+use Cake\View\StringTemplate;
|
|
|
+
|
|
|
+/**
|
|
|
+ * InputRegistry test case
|
|
|
+ */
|
|
|
+class InputRegistryTestCase extends TestCase {
|
|
|
+
|
|
|
+/**
|
|
|
+ * setup method
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function setUp() {
|
|
|
+ parent::setUp();
|
|
|
+ $this->templates = new StringTemplate();
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * Test adding new widgets.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testAdd() {
|
|
|
+ $this->markTestIncomplete();
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * Test getting registered widgets.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testGet() {
|
|
|
+ $this->markTestIncomplete();
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * Test getting fallback widgets.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testGetFallback() {
|
|
|
+ $this->markTestIncomplete();
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * Test getting errors
|
|
|
+ *
|
|
|
+ * @expectedException RuntimeException
|
|
|
+ * @expectedExceptionMessage Unknown widget "foo"
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testGetNoFallbackError() {
|
|
|
+ $inputs = new InputRegistry($this->templates);
|
|
|
+ $inputs->get('foo');
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * Test getting resolve dependency
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testGetResolveDependency() {
|
|
|
+ $inputs = new InputRegistry($this->templates);
|
|
|
+ $inputs->add([
|
|
|
+ 'label' => ['Cake\View\Input\Label'],
|
|
|
+ 'multicheckbox' => ['Cake\View\Input\MultiCheckbox', 'label']
|
|
|
+ ]);
|
|
|
+ $result = $inputs->get('multicheckbox');
|
|
|
+ $this->assertInstanceOf('CakeView\Input\MultiCheckbox', $result);
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * Test getting resolve dependency missing class
|
|
|
+ *
|
|
|
+ * @expectedException RuntimeException
|
|
|
+ * @expectedExceptionMessage Unable to locate widget class "TestApp\View\Derp"
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testGetResolveDependencyMissingClass() {
|
|
|
+ $inputs = new InputRegistry($this->templates);
|
|
|
+ $inputs->add(['test' => ['TestApp\View\Derp']]);
|
|
|
+ $inputs->get('test');
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * Test getting resolve dependency missing dependency
|
|
|
+ *
|
|
|
+ * @expectedException RuntimeException
|
|
|
+ * @expectedExceptionMessage Unknown widget "label"
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testGetResolveDependencyMissingDependency() {
|
|
|
+ $inputs = new InputRegistry($this->templates);
|
|
|
+ $inputs->add(['multicheckbox' => ['Cake\View\Input\MultiCheckbox', 'label']]);
|
|
|
+ $inputs->get('multicheckbox');
|
|
|
+ }
|
|
|
+
|
|
|
+}
|