Browse Source

Fix classes to standalone class files. Removed dead files.

mscherer 7 years ago
parent
commit
e4db0dec9d

+ 5 - 62
tests/TestCase/Core/InstanceConfigTraitTest.php

@@ -15,74 +15,17 @@ declare(strict_types=1);
  */
 namespace Cake\Test\TestCase\Core;
 
-use Cake\Core\InstanceConfigTrait;
 use Cake\TestSuite\TestCase;
-use Exception;
+use TestApp\Config\ReadOnlyTestInstanceConfig;
+use TestApp\Config\TestInstanceConfig;
 
-/**
- * TestInstanceConfig
- */
-class TestInstanceConfig
-{
-    use InstanceConfigTrait;
-
-    /**
-     * _defaultConfig
-     *
-     * Some default config
-     *
-     * @var array
-     */
-    protected $_defaultConfig = [
-        'some' => 'string',
-        'a' => [
-            'nested' => 'value',
-            'other' => 'value',
-        ],
-    ];
-}
-
-/**
- * ReadOnlyTestInstanceConfig
- */
-class ReadOnlyTestInstanceConfig
+class InstanceConfigTraitTest extends TestCase
 {
-    use InstanceConfigTrait;
-
     /**
-     * _defaultConfig
-     *
-     * Some default config
-     *
-     * @var array
-     */
-    protected $_defaultConfig = [
-        'some' => 'string',
-        'a' => [
-            'nested' => 'value',
-            'other' => 'value',
-        ],
-    ];
-
-    /**
-     * Example of how to prevent modifying config at run time
-     *
-     * @throws \Exception
-     * @param mixed $key
-     * @param mixed $value
-     * @return void
+     * @var \TestApp\Config\TestInstanceConfig
      */
-    protected function _configWrite($key, $value = null)
-    {
-        throw new Exception('This Instance is readonly');
-    }
-}
+    protected $object;
 
-/**
- * InstanceConfigTraitTest
- */
-class InstanceConfigTraitTest extends TestCase
-{
     /**
      * setUp method
      *

+ 11 - 60
tests/TestCase/Database/ExpressionTypeCastingIntegrationTest.php

@@ -14,68 +14,14 @@ declare(strict_types=1);
  */
 namespace Cake\Test\TestCase\Database;
 
-use Cake\Database\Driver;
 use Cake\Database\Driver\Sqlserver;
-use Cake\Database\Expression\FunctionExpression;
-use Cake\Database\ExpressionInterface;
-use Cake\Database\Type\BaseType;
-use Cake\Database\Type\ExpressionTypeInterface;
+use Cake\Database\Expression\QueryExpression;
+use Cake\Database\Query;
 use Cake\Database\TypeFactory;
 use Cake\Datasource\ConnectionManager;
 use Cake\TestSuite\TestCase;
-
-/**
- * Value object for testing mappings.
- */
-class UuidValue
-{
-    public $value;
-
-    public function __construct($value)
-    {
-        $this->value = $value;
-    }
-}
-
-/**
- * Custom type class that maps between value objects, and SQL expressions.
- */
-class OrderedUuidType extends BaseType implements ExpressionTypeInterface
-{
-    public function toPHP($value, Driver $d)
-    {
-        return new UuidValue($value);
-    }
-
-    public function toExpression($value): ExpressionInterface
-    {
-        if ($value instanceof UuidValue) {
-            $value = $value->value;
-        }
-        $substr = function ($start, $length = null) use ($value) {
-            return new FunctionExpression(
-                'SUBSTR',
-                $length === null ? [$value, $start] : [$value, $start, $length],
-                ['string', 'integer', 'integer']
-            );
-        };
-
-        return new FunctionExpression(
-            'CONCAT',
-            [$substr(15, 4), $substr(10, 4), $substr(1, 8), $substr(20, 4), $substr(25)]
-        );
-    }
-
-    public function marshal($value)
-    {
-        return $value;
-    }
-
-    public function toDatabase($value, Driver $d)
-    {
-        return $value;
-    }
-}
+use TestApp\Database\Type\OrderedUuidType;
+use TestApp\Database\Type\UuidValue;
 
 /**
  * Tests for Expression objects casting values to other expressions
@@ -86,6 +32,11 @@ class ExpressionTypeCastingIntegrationTest extends TestCase
 {
     public $fixtures = ['core.OrderedUuidItems'];
 
+    /**
+     * @var \Cake\Database\Connection
+     */
+    protected $connection;
+
     public function setUp()
     {
         parent::setUp();
@@ -203,7 +154,7 @@ class ExpressionTypeCastingIntegrationTest extends TestCase
         $result = $this->connection->newQuery()
             ->select('id')
             ->from('ordered_uuid_items')
-            ->where(function ($exp) {
+            ->where(function (QueryExpression $exp) {
                 return $exp->between(
                     'id',
                     '482b7756-8da0-419a-b21f-27da40cf8569',
@@ -228,7 +179,7 @@ class ExpressionTypeCastingIntegrationTest extends TestCase
         $result = $this->connection->newQuery()
             ->select('id')
             ->from('ordered_uuid_items')
-            ->where(function ($exp, $q) {
+            ->where(function (QueryExpression $exp, Query $q) {
                 return $exp->eq(
                     'id',
                     $q->func()->concat(['48298a29-81c0-4c26-a7fb', '-413140cf8569'], []),

+ 1 - 11
tests/TestCase/Database/ExpressionTypeCastingTest.php

@@ -19,21 +19,11 @@ use Cake\Database\Expression\CaseExpression;
 use Cake\Database\Expression\Comparison;
 use Cake\Database\Expression\FunctionExpression;
 use Cake\Database\Expression\ValuesExpression;
-use Cake\Database\ExpressionInterface;
-use Cake\Database\Type\ExpressionTypeInterface;
-use Cake\Database\Type\StringType;
 use Cake\Database\TypeFactory;
 use Cake\Database\TypeMap;
 use Cake\Database\ValueBinder;
 use Cake\TestSuite\TestCase;
-
-class TestType extends StringType implements ExpressionTypeInterface
-{
-    public function toExpression($value): ExpressionInterface
-    {
-        return new FunctionExpression('CONCAT', [$value, ' - foo']);
-    }
-}
+use TestApp\Database\Type\TestType;
 
 /**
  * Tests for Expression objects casting values to other expressions

+ 6 - 17
tests/TestCase/Database/Schema/TableSchemaTest.php

@@ -16,26 +16,15 @@ declare(strict_types=1);
 namespace Cake\Test\TestCase\Database\Schema;
 
 use Cake\Database\Schema\TableSchema;
-use Cake\Database\Type\IntegerType;
 use Cake\Database\TypeFactory;
 use Cake\Datasource\ConnectionManager;
 use Cake\TestSuite\TestCase;
-
-/**
- * Mock class for testing baseType inheritance
- */
-class FooType extends IntegerType
-{
-    public function getBaseType(): string
-    {
-        return 'integer';
-    }
-}
+use TestApp\Database\Type\IntType;
 
 /**
  * Test case for Table
  */
-class TableTest extends TestCase
+class TableSchemaTest extends TestCase
 {
     public $fixtures = [
         'core.Articles',
@@ -215,19 +204,19 @@ class TableTest extends TestCase
     }
 
     /**
-     * Tests getting the base type as it is retuned by the Type class
+     * Tests getting the base type as it is returned by the Type class
      *
      * @return void
      */
     public function testBaseColumnTypeInherited()
     {
-        TypeFactory::map('foo', __NAMESPACE__ . '\FooType');
+        TypeFactory::map('int', IntType::class);
         $table = new TableSchema('articles');
         $table->addColumn('thing', [
-            'type' => 'foo',
+            'type' => 'int',
             'null' => false,
         ]);
-        $this->assertEquals('foo', $table->getColumnType('thing'));
+        $this->assertEquals('int', $table->getColumnType('thing'));
         $this->assertEquals('integer', $table->baseColumnType('thing'));
     }
 

+ 2 - 24
tests/TestCase/Log/Engine/BaseLogTest.php

@@ -14,32 +14,10 @@ declare(strict_types=1);
  */
 namespace Cake\Test\TestCase\Log\Engine;
 
-use Cake\Log\Engine\BaseLog;
 use Cake\ORM\Entity;
 use Cake\TestSuite\TestCase;
 use Psr\Log\LogLevel;
-
-/**
- * Class BaseLogImpl
- * Implementation of abstract class {@see Cake\Log\Engine\BaseLog},
- * required by test case {@see Cake\Test\TestCase\Log\Engine\BaseLogTest}.
- */
-class BaseLogImpl extends BaseLog
-{
-    /**
-     * Logs with an arbitrary level.
-     *
-     * @param mixed $level
-     * @param mixed $message
-     * @param array $context
-     *
-     * @return mixed
-     */
-    public function log($level, $message, array $context = [])
-    {
-        return $this->_format($message, $context);
-    }
-}
+use TestApp\Log\Engine\TestBaseLog;
 
 class BaseLogTest extends TestCase
 {
@@ -55,7 +33,7 @@ class BaseLogTest extends TestCase
     {
         parent::setUp();
 
-        $this->logger = new BaseLogImpl();
+        $this->logger = new TestBaseLog();
     }
 
     private function assertUnescapedUnicode(array $needles, $haystack)

+ 2 - 33
tests/TestCase/Log/Engine/FileLogTest.php

@@ -19,39 +19,8 @@ namespace Cake\Test\TestCase\Log\Engine;
 
 use Cake\Log\Engine\FileLog;
 use Cake\TestSuite\TestCase;
-use JsonSerializable;
-
-/**
- * used for testing when an object is passed to a logger
- */
-class StringObject
-{
-    /**
-     * String representation of the object
-     *
-     * @return string
-     */
-    public function __toString()
-    {
-        return 'Hey!';
-    }
-}
-
-/**
- * used for testing when an serializable is passed to a logger
- */
-class JsonObject implements JsonSerializable
-{
-    /**
-     * String representation of the object
-     *
-     * @return array
-     */
-    public function jsonSerialize()
-    {
-        return ['hello' => 'world'];
-    }
-}
+use TestApp\Log\Object\JsonObject;
+use TestApp\Log\Object\StringObject;
 
 /**
  * FileLogTest class

+ 8 - 4
tests/TestCase/Log/Engine/SyslogLogTest.php

@@ -15,6 +15,7 @@ declare(strict_types=1);
  */
 namespace Cake\Test\TestCase\Log\Engine;
 
+use Cake\Log\Engine\SyslogLog;
 use Cake\TestSuite\TestCase;
 
 /**
@@ -29,13 +30,14 @@ class SyslogLogTest extends TestCase
      */
     public function testOpenLog()
     {
-        $log = $this->getMockBuilder('Cake\Log\Engine\SyslogLog')
+        /** @var \Cake\Log\Engine\SyslogLog|\PHPUnit\Framework\MockObject\MockObject $log */
+        $log = $this->getMockBuilder(SyslogLog::class)
             ->setMethods(['_open', '_write'])
             ->getMock();
         $log->expects($this->once())->method('_open')->with('', LOG_ODELAY, LOG_USER);
         $log->log('debug', 'message');
 
-        $log = $this->getMockBuilder('Cake\Log\Engine\SyslogLog')
+        $log = $this->getMockBuilder(SyslogLog::class)
             ->setMethods(['_open', '_write'])
             ->getMock();
         $log->setConfig([
@@ -57,7 +59,8 @@ class SyslogLogTest extends TestCase
      */
     public function testWriteOneLine($type, $expected)
     {
-        $log = $this->getMockBuilder('Cake\Log\Engine\SyslogLog')
+        /** @var \Cake\Log\Engine\SyslogLog|\PHPUnit\Framework\MockObject\MockObject $log */
+        $log = $this->getMockBuilder(SyslogLog::class)
             ->setMethods(['_open', '_write'])
             ->getMock();
         $log->expects($this->once())->method('_write')->with($expected, $type . ': Foo');
@@ -71,7 +74,8 @@ class SyslogLogTest extends TestCase
      */
     public function testWriteMultiLine()
     {
-        $log = $this->getMockBuilder('Cake\Log\Engine\SyslogLog')
+        /** @var \Cake\Log\Engine\SyslogLog|\PHPUnit\Framework\MockObject\MockObject $log */
+        $log = $this->getMockBuilder(SyslogLog::class)
             ->setMethods(['_open', '_write'])
             ->getMock();
         $log->expects($this->at(1))->method('_write')->with(LOG_DEBUG, 'debug: Foo');

+ 0 - 22
tests/test_app/Plugin/TestPlugin/src/Vendor/sample/sample_plugin.php

@@ -1,22 +0,0 @@
-<?php
-declare(strict_types=1);
-/**
- * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
- * Copyright (c) Cake Software Foundation, Inc. (https://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. (https://cakefoundation.org)
- * @link          https://cakephp.org CakePHP(tm) Project
- * @since         1.2.0
- * @license       https://opensource.org/licenses/mit-license.php MIT License
- */
-
-/**
- * SamplePluginClassTestName
- */
-class SamplePluginClassTestName
-{
-}

+ 39 - 0
tests/test_app/TestApp/Config/ReadOnlyTestInstanceConfig.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace TestApp\Config;
+
+use Cake\Core\InstanceConfigTrait;
+use Exception;
+
+class ReadOnlyTestInstanceConfig
+{
+    use InstanceConfigTrait;
+
+    /**
+     * _defaultConfig
+     *
+     * Some default config
+     *
+     * @var array
+     */
+    protected $_defaultConfig = [
+        'some' => 'string',
+        'a' => [
+            'nested' => 'value',
+            'other' => 'value',
+        ],
+    ];
+
+    /**
+     * Example of how to prevent modifying config at run time
+     *
+     * @throws \Exception
+     * @param mixed $key
+     * @param mixed $value
+     * @return void
+     */
+    protected function _configWrite($key, $value = null)
+    {
+        throw new Exception('This Instance is readonly');
+    }
+}

+ 25 - 0
tests/test_app/TestApp/Config/TestInstanceConfig.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace TestApp\Config;
+
+use Cake\Core\InstanceConfigTrait;
+
+class TestInstanceConfig
+{
+    use InstanceConfigTrait;
+
+    /**
+     * _defaultConfig
+     *
+     * Some default config
+     *
+     * @var array
+     */
+    protected $_defaultConfig = [
+        'some' => 'string',
+        'a' => [
+            'nested' => 'value',
+            'other' => 'value',
+        ],
+    ];
+}

+ 16 - 0
tests/test_app/TestApp/Database/Type/IntType.php

@@ -0,0 +1,16 @@
+<?php
+declare(strict_types=1);
+namespace TestApp\Database\Type;
+
+use Cake\Database\Type\IntegerType;
+
+/**
+ * Mock class for testing baseType inheritance
+ */
+class IntType extends IntegerType
+{
+    public function getBaseType(): string
+    {
+        return 'integer';
+    }
+}

+ 49 - 0
tests/test_app/TestApp/Database/Type/OrderedUuidType.php

@@ -0,0 +1,49 @@
+<?php
+declare(strict_types=1);
+namespace TestApp\Database\Type;
+
+use Cake\Database\Driver;
+use Cake\Database\Expression\FunctionExpression;
+use Cake\Database\ExpressionInterface;
+use Cake\Database\Type\BaseType;
+use Cake\Database\Type\ExpressionTypeInterface;
+
+/**
+ * Custom type class that maps between value objects, and SQL expressions.
+ */
+class OrderedUuidType extends BaseType implements ExpressionTypeInterface
+{
+    public function toPHP($value, Driver $d)
+    {
+        return new UuidValue($value);
+    }
+
+    public function toExpression($value): ExpressionInterface
+    {
+        if ($value instanceof UuidValue) {
+            $value = $value->value;
+        }
+        $substr = function ($start, $length = null) use ($value) {
+            return new FunctionExpression(
+                'SUBSTR',
+                $length === null ? [$value, $start] : [$value, $start, $length],
+                ['string', 'integer', 'integer']
+            );
+        };
+
+        return new FunctionExpression(
+            'CONCAT',
+            [$substr(15, 4), $substr(10, 4), $substr(1, 8), $substr(20, 4), $substr(25)]
+        );
+    }
+
+    public function marshal($value)
+    {
+        return $value;
+    }
+
+    public function toDatabase($value, Driver $d)
+    {
+        return $value;
+    }
+}

+ 16 - 0
tests/test_app/TestApp/Database/Type/TestType.php

@@ -0,0 +1,16 @@
+<?php
+declare(strict_types=1);
+namespace TestApp\Database\Type;
+
+use Cake\Database\Expression\FunctionExpression;
+use Cake\Database\ExpressionInterface;
+use Cake\Database\Type\ExpressionTypeInterface;
+use Cake\Database\Type\StringType;
+
+class TestType extends StringType implements ExpressionTypeInterface
+{
+    public function toExpression($value): ExpressionInterface
+    {
+        return new FunctionExpression('CONCAT', [$value, ' - foo']);
+    }
+}

+ 16 - 0
tests/test_app/TestApp/Database/Type/UuidValue.php

@@ -0,0 +1,16 @@
+<?php
+declare(strict_types=1);
+namespace TestApp\Database\Type;
+
+/**
+ * Value object for testing mappings.
+ */
+class UuidValue
+{
+    public $value;
+
+    public function __construct($value)
+    {
+        $this->value = $value;
+    }
+}

+ 27 - 0
tests/test_app/TestApp/Log/Engine/TestBaseLog.php

@@ -0,0 +1,27 @@
+<?php
+declare(strict_types=1);
+namespace TestApp\Log\Engine;
+
+use Cake\Log\Engine\BaseLog;
+
+/**
+ * Class BaseLogImpl
+ * Implementation of abstract class {@see Cake\Log\Engine\BaseLog},
+ * required by test case {@see Cake\Test\TestCase\Log\Engine\BaseLogTest}.
+ */
+class TestBaseLog extends BaseLog
+{
+    /**
+     * Logs with an arbitrary level.
+     *
+     * @param mixed $level
+     * @param string $message
+     * @param array $context
+     *
+     * @return string
+     */
+    public function log($level, $message, array $context = [])
+    {
+        return $this->_format($message, $context);
+    }
+}

+ 21 - 0
tests/test_app/TestApp/Log/Object/JsonObject.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace TestApp\Log\Object;
+
+use JsonSerializable;
+
+/**
+ * used for testing when an serializable is passed to a logger
+ */
+class JsonObject implements JsonSerializable
+{
+    /**
+     * String representation of the object
+     *
+     * @return array
+     */
+    public function jsonSerialize()
+    {
+        return ['hello' => 'world'];
+    }
+}

+ 19 - 0
tests/test_app/TestApp/Log/Object/StringObject.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace TestApp\Log\Object;
+
+/**
+ * used for testing when an object is passed to a logger
+ */
+class StringObject
+{
+    /**
+     * String representation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return 'Hey!';
+    }
+}

+ 0 - 22
tests/test_app/vendor/sample/configure_test_vendor_sample.php

@@ -1,22 +0,0 @@
-<?php
-declare(strict_types=1);
-/**
- * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
- * Copyright (c) Cake Software Foundation, Inc. (https://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. (https://cakefoundation.org)
- * @link          https://cakephp.org CakePHP(tm) Project
- * @since         1.2.0
- * @license       https://opensource.org/licenses/mit-license.php MIT License
- */
-
-/**
- * ConfigureTestVendorSample
- */
-class ConfigureTestVendorSample
-{
-}