Browse Source

Move test classes into their own files.

ADmad 7 years ago
parent
commit
003657662c

+ 1 - 162
tests/TestCase/Controller/ControllerTest.php

@@ -26,6 +26,7 @@ use Cake\TestSuite\TestCase;
 use PHPUnit\Framework\Error\Notice;
 use PHPUnit\Framework\Error\Warning;
 use TestApp\Controller\Admin\PostsController;
+use TestApp\Controller\TestController;
 use TestPlugin\Controller\TestPluginController;
 
 /**
@@ -1052,165 +1053,3 @@ class ControllerTest extends TestCase
         $this->assertTrue($controller->isAutoRenderEnabled());
     }
 }
-
-/**
- * AppController class
- */
-class ControllerTestAppController extends Controller
-{
-    /**
-     * modelClass property
-     *
-     * @var string
-     */
-    public $modelClass = 'Posts';
-}
-
-/**
- * TestController class
- */
-class TestController extends ControllerTestAppController
-{
-    /**
-     * Theme property
-     *
-     * @var string
-     */
-    public $theme = 'Foo';
-
-    /**
-     * modelClass property
-     *
-     * @var string
-     */
-    public $modelClass = 'Comments';
-
-    /**
-     * beforeFilter handler
-     *
-     * @param \Cake\Event\EventInterface $event
-     * @return \Cake\Http\Response|null
-     */
-    public function beforeFilter(EventInterface $event): ?Response
-    {
-    }
-
-    /**
-     * index method
-     *
-     * @param mixed $testId
-     * @param mixed $testTwoId
-     * @return void
-     */
-    public function index($testId, $testTwoId): void
-    {
-        $this->request = $this->request->withParsedBody([
-            'testId' => $testId,
-            'test2Id' => $testTwoId,
-        ]);
-    }
-
-    /**
-     * view method
-     *
-     * @param mixed $testId
-     * @param mixed $testTwoId
-     * @return void
-     */
-    public function view($testId, $testTwoId): void
-    {
-        $this->request = $this->request->withParsedBody([
-            'testId' => $testId,
-            'test2Id' => $testTwoId,
-        ]);
-    }
-
-    public function returner()
-    {
-        return 'I am from the controller.';
-    }
-
-    // phpcs:disable
-    protected function protected_m()
-    {
-    }
-
-    private function private_m()
-    {
-    }
-
-    public function _hidden()
-    {
-    }
-    // phpcs:enable
-
-    public function admin_add(): void
-    {
-    }
-}
-
-/**
- * TestComponent class
- */
-class TestComponent extends Component
-{
-    /**
-     * beforeRedirect method
-     *
-     * @return void
-     */
-    public function beforeRedirect(): void
-    {
-    }
-
-    /**
-     * initialize method
-     *
-     * @param array $config
-     * @return void
-     */
-    public function initialize(array $config): void
-    {
-    }
-
-    /**
-     * startup method
-     *
-     * @param \Cake\Event\EventInterface $event
-     * @return void
-     */
-    public function startup(EventInterface $event): void
-    {
-    }
-
-    /**
-     * shutdown method
-     *
-     * @param \Cake\Event\EventInterface $event
-     * @return void
-     */
-    public function shutdown(EventInterface $event): void
-    {
-    }
-
-    /**
-     * beforeRender callback
-     *
-     * @param \Cake\Event\EventInterface $event
-     * @return void
-     */
-    public function beforeRender(EventInterface $event): void
-    {
-        $controller = $event->getSubject();
-        if ($this->viewclass) {
-            $controller->viewClass = $this->viewclass;
-        }
-    }
-}
-
-/**
- * AnotherTestController class
- */
-class AnotherTestController extends ControllerTestAppController
-{
-}

+ 0 - 41
tests/TestCase/Error/ExceptionRendererTest.php

@@ -942,44 +942,3 @@ class ExceptionRendererTest extends TestCase
         $this->assertContains("'seven' => (int) 7", $result);
     }
 }
-
-class TestErrorController extends Controller
-{
-    /**
-     * uses property
-     *
-     * @var array
-     */
-    public $uses = [];
-
-    /**
-     * components property
-     *
-     * @return void
-     */
-    public $components = ['Blueberry'];
-
-    /**
-     * beforeRender method
-     *
-     * @return \Cake\Http\Response|null
-     */
-    public function beforeRender(EventInterface $event): ?Response
-    {
-        echo $this->Blueberry->testName;
-
-        return null;
-    }
-
-    /**
-     * index method
-     *
-     * @return array
-     */
-    public function index()
-    {
-        $this->autoRender = false;
-
-        return 'what up';
-    }
-}

+ 3 - 56
tests/TestCase/Utility/MergeVariablesTraitTest.php

@@ -17,6 +17,9 @@ namespace Cake\Test\TestCase\Utility;
 
 use Cake\TestSuite\TestCase;
 use Cake\Utility\MergeVariablesTrait;
+use TestApp\Utility\Base;
+use TestApp\Utility\Child;
+use TestApp\Utility\Grandchild;
 
 /**
  * MergeVariablesTrait test case
@@ -111,59 +114,3 @@ class MergeVariablesTraitTest extends TestCase
         $this->assertEquals(['test'], $object->hasBoolean);
     }
 }
-
-class Base
-{
-    use MergeVariablesTrait;
-
-    public $hasBoolean = false;
-
-    public $listProperty = ['One'];
-
-    public $assocProperty = ['Red'];
-
-    public function mergeVars($properties, $options = [])
-    {
-        return $this->_mergeVars($properties, $options);
-    }
-}
-
-class Child extends Base
-{
-    public $hasBoolean = ['test'];
-
-    public $listProperty = ['Two', 'Three'];
-
-    public $assocProperty = [
-        'Green' => ['lime'],
-        'Orange',
-    ];
-
-    public $nestedProperty = [
-        'Red' => [
-            'apple' => 'gala',
-        ],
-        'Green' => [
-            'citrus' => 'lime',
-        ],
-    ];
-}
-
-class Grandchild extends Child
-{
-    public $listProperty = ['Four', 'Five'];
-
-    public $assocProperty = [
-        'Green' => ['apple'],
-        'Yellow' => ['banana'],
-    ];
-
-    public $nestedProperty = [
-        'Red' => [
-            'citrus' => 'blood orange',
-        ],
-        'Green' => [
-            'citrus' => 'key lime',
-        ],
-    ];
-}

+ 18 - 0
tests/test_app/TestApp/Controller/ControllerTestAppController.php

@@ -0,0 +1,18 @@
+<?php
+declare(strict_types=1);
+namespace TestApp\Controller;
+
+use Cake\Controller\Controller;
+
+/**
+ * AppController class
+ */
+class ControllerTestAppController extends Controller
+{
+    /**
+     * modelClass property
+     *
+     * @var string
+     */
+    public $modelClass = 'Posts';
+}

+ 88 - 0
tests/test_app/TestApp/Controller/TestController.php

@@ -0,0 +1,88 @@
+<?php
+declare(strict_types=1);
+namespace TestApp\Controller;
+
+use Cake\Event\EventInterface;
+
+/**
+ * TestController class
+ */
+class TestController extends ControllerTestAppController
+{
+    /**
+     * Theme property
+     *
+     * @var string
+     */
+    public $theme = 'Foo';
+
+    /**
+     * modelClass property
+     *
+     * @var string
+     */
+    public $modelClass = 'Comments';
+
+    /**
+     * beforeFilter handler
+     *
+     * @param \Cake\Event\EventInterface $event
+     * @return \Cake\Http\Response|null
+     */
+    public function beforeFilter(EventInterface $event): ?Response
+    {
+    }
+
+    /**
+     * index method
+     *
+     * @param mixed $testId
+     * @param mixed $testTwoId
+     * @return void
+     */
+    public function index($testId, $testTwoId): void
+    {
+        $this->request = $this->request->withParsedBody([
+            'testId' => $testId,
+            'test2Id' => $testTwoId,
+        ]);
+    }
+
+    /**
+     * view method
+     *
+     * @param mixed $testId
+     * @param mixed $testTwoId
+     * @return void
+     */
+    public function view($testId, $testTwoId): void
+    {
+        $this->request = $this->request->withParsedBody([
+            'testId' => $testId,
+            'test2Id' => $testTwoId,
+        ]);
+    }
+
+    public function returner()
+    {
+        return 'I am from the controller.';
+    }
+
+    // phpcs:disable
+    protected function protected_m()
+    {
+    }
+
+    private function private_m()
+    {
+    }
+
+    public function _hidden()
+    {
+    }
+    // phpcs:enable
+
+    public function admin_add(): void
+    {
+    }
+}

+ 21 - 0
tests/test_app/TestApp/Utility/Base.php

@@ -0,0 +1,21 @@
+<?php
+declare(strict_types=1);
+namespace TestApp\Utility;
+
+use Cake\Utility\MergeVariablesTrait;
+
+class Base
+{
+    use MergeVariablesTrait;
+
+    public $hasBoolean = false;
+
+    public $listProperty = ['One'];
+
+    public $assocProperty = ['Red'];
+
+    public function mergeVars($properties, $options = [])
+    {
+        return $this->_mergeVars($properties, $options);
+    }
+}

+ 24 - 0
tests/test_app/TestApp/Utility/Child.php

@@ -0,0 +1,24 @@
+<?php
+declare(strict_types=1);
+namespace TestApp\Utility;
+
+class Child extends Base
+{
+    public $hasBoolean = ['test'];
+
+    public $listProperty = ['Two', 'Three'];
+
+    public $assocProperty = [
+        'Green' => ['lime'],
+        'Orange',
+    ];
+
+    public $nestedProperty = [
+        'Red' => [
+            'apple' => 'gala',
+        ],
+        'Green' => [
+            'citrus' => 'lime',
+        ],
+    ];
+}

+ 22 - 0
tests/test_app/TestApp/Utility/Grandchild.php

@@ -0,0 +1,22 @@
+<?php
+declare(strict_types=1);
+namespace TestApp\Utility;
+
+class Grandchild extends Child
+{
+    public $listProperty = ['Four', 'Five'];
+
+    public $assocProperty = [
+        'Green' => ['apple'],
+        'Yellow' => ['banana'],
+    ];
+
+    public $nestedProperty = [
+        'Red' => [
+            'citrus' => 'blood orange',
+        ],
+        'Green' => [
+            'citrus' => 'key lime',
+        ],
+    ];
+}