Browse Source

Merge branch 'master' into 3.1

Mark Story 11 years ago
parent
commit
53fbde2fa9
31 changed files with 208 additions and 176 deletions
  1. 1 1
      src/Cache/Engine/MemcachedEngine.php
  2. 13 0
      src/Collection/Collection.php
  3. 1 1
      src/Controller/Controller.php
  4. 5 4
      src/Core/Plugin.php
  5. 4 2
      src/Database/Schema/SqliteSchema.php
  6. 3 4
      src/Datasource/QueryTrait.php
  7. 1 1
      src/Error/ExceptionRenderer.php
  8. 6 0
      src/ORM/Association/BelongsToMany.php
  9. 15 8
      src/ORM/Marshaller.php
  10. 1 1
      src/TestSuite/Fixture/FixtureManager.php
  11. 2 1
      src/TestSuite/TestCase.php
  12. 1 1
      src/Utility/Hash.php
  13. 1 1
      src/Validation/Validator.php
  14. 14 0
      src/View/Helper/SessionHelper.php
  15. 2 1
      tests/Fixture/FixturizedTestCase.php
  16. 42 0
      tests/TestCase/Collection/CollectionTest.php
  17. 2 2
      tests/TestCase/Controller/Component/FlashComponentTest.php
  18. 1 2
      tests/TestCase/Controller/ControllerTest.php
  19. 2 1
      tests/TestCase/Core/InstanceConfigTraitTest.php
  20. 9 8
      tests/TestCase/Error/ExceptionRendererTest.php
  21. 2 4
      tests/TestCase/Network/Email/EmailTest.php
  22. 1 1
      tests/TestCase/ORM/Association/BelongsToManyTest.php
  23. 1 0
      tests/TestCase/ORM/CompositeKeysTest.php
  24. 49 0
      tests/TestCase/ORM/MarshallerTest.php
  25. 19 3
      tests/TestCase/ORM/TableTest.php
  26. 2 4
      tests/TestCase/TestSuite/TestFixtureTest.php
  27. 3 0
      tests/TestCase/Utility/HashTest.php
  28. 0 117
      tests/TestCase/View/Helper/SessionHelperTest.php
  29. 4 6
      tests/TestCase/View/ViewTest.php
  30. 1 1
      tests/test_app/TestApp/Controller/PagesController.php
  31. 0 1
      tests/test_app/TestApp/Controller/TestAppsErrorController.php

+ 1 - 1
src/Cache/Engine/MemcachedEngine.php

@@ -24,7 +24,7 @@ use Memcached;
  * more information.
  *
  * Main advantage of this Memcached engine over the memcached engine is
- * support of binary protocol, and igbibnary serialization
+ * support of binary protocol, and igbinary serialization
  * (if memcached extension compiled with --enable-igbinary)
  * Compressed keys can also be incremented/decremented
  *

+ 13 - 0
src/Collection/Collection.php

@@ -48,4 +48,17 @@ class Collection extends IteratorIterator implements CollectionInterface
 
         parent::__construct($items);
     }
+
+    /**
+     * Returns an array that can be used to describe the internal state of this
+     * object.
+     *
+     * @return array
+     */
+    public function __debugInfo()
+    {
+        return [
+            'count' => iterator_count($this),
+        ];
+    }
 }

+ 1 - 1
src/Controller/Controller.php

@@ -165,7 +165,7 @@ class Controller implements EventListenerInterface
      * Array containing the names of components this controller uses. Component names
      * should not contain the "Component" portion of the class name.
      *
-     * Example: `public $components = ['Session', 'RequestHandler', 'Acl'];`
+     * Example: `public $components = ['RequestHandler', 'Acl'];`
      *
      * @var array
      * @link http://book.cakephp.org/3.0/en/controllers/components.html

+ 5 - 4
src/Core/Plugin.php

@@ -16,6 +16,7 @@ namespace Cake\Core;
 
 use Cake\Core\ClassLoader;
 use Cake\Core\Configure;
+use Cake\Core\Exception\MissingPluginException;
 use DirectoryIterator;
 
 /**
@@ -146,7 +147,7 @@ class Plugin
         }
 
         if (empty($config['path'])) {
-            throw new Exception\MissingPluginException(['plugin' => $plugin]);
+            throw new MissingPluginException(['plugin' => $plugin]);
         }
 
         $config['classPath'] = $config['path'] . $config['classBase'] . DS;
@@ -260,7 +261,7 @@ class Plugin
     public static function path($plugin)
     {
         if (empty(static::$_plugins[$plugin])) {
-            throw new Exception\MissingPluginException(['plugin' => $plugin]);
+            throw new MissingPluginException(['plugin' => $plugin]);
         }
         return static::$_plugins[$plugin]['path'];
     }
@@ -275,7 +276,7 @@ class Plugin
     public static function classPath($plugin)
     {
         if (empty(static::$_plugins[$plugin])) {
-            throw new Exception\MissingPluginException(['plugin' => $plugin]);
+            throw new MissingPluginException(['plugin' => $plugin]);
         }
         return static::$_plugins[$plugin]['classPath'];
     }
@@ -290,7 +291,7 @@ class Plugin
     public static function configPath($plugin)
     {
         if (empty(static::$_plugins[$plugin])) {
-            throw new Exception\MissingPluginException(['plugin' => $plugin]);
+            throw new MissingPluginException(['plugin' => $plugin]);
         }
         return static::$_plugins[$plugin]['configPath'];
     }

+ 4 - 2
src/Database/Schema/SqliteSchema.php

@@ -207,12 +207,14 @@ class SqliteSchema extends BaseSchema
      */
     public function convertForeignKeyDescription(Table $table, $row)
     {
+        $update = isset($row['on_update']) ? $row['on_update'] : '';
+        $delete = isset($row['on_delete']) ? $row['on_delete'] : '';
         $data = [
             'type' => Table::CONSTRAINT_FOREIGN,
             'columns' => [$row['from']],
             'references' => [$row['table'], $row['to']],
-            'update' => $this->_convertOnClause($row['on_update']),
-            'delete' => $this->_convertOnClause($row['on_delete']),
+            'update' => $this->_convertOnClause($update),
+            'delete' => $this->_convertOnClause($delete),
         ];
         $name = $row['from'] . '_fk';
         $table->addConstraint($name, $data);

+ 3 - 4
src/Datasource/QueryTrait.php

@@ -270,8 +270,7 @@ trait QueryTrait
      * to fetch the results from the database.
      *
      * Formatting callbacks will get a first parameter, a `ResultSetDecorator`, that
-     * can be traversed and modified at will. As for the second parameter, the
-     * formatting callback will receive this query instance.
+     * can be traversed and modified at will.
      *
      * Callbacks are required to return an iterator object, which will be used as
      * the return value for this query's result. Formatter functions are applied
@@ -287,12 +286,12 @@ trait QueryTrait
      *
      * ```
      * // Return all results from the table indexed by id
-     * $query->select(['id', 'name'])->formatResults(function ($results, $query) {
+     * $query->select(['id', 'name'])->formatResults(function ($results) {
      *   return $results->indexBy('id');
      * });
      *
      * // Add a new column to the ResultSet
-     * $query->select(['name', 'birth_date'])->formatResults(function ($results, $query) {
+     * $query->select(['name', 'birth_date'])->formatResults(function ($results) {
      *   return $results->map(function ($row) {
      *     $row['age'] = $row['birth_date']->diff(new DateTime)->y;
      *     return $row;

+ 1 - 1
src/Error/ExceptionRenderer.php

@@ -334,7 +334,7 @@ class ExceptionRenderer
         $this->controller->subDir = null;
         $this->controller->viewPath = 'Error';
         $this->controller->layout = 'error';
-        $this->controller->helpers = ['Form', 'Html', 'Session'];
+        $this->controller->helpers = ['Form', 'Html'];
 
         $view = $this->controller->createView();
         $this->controller->response->body($view->render($template, 'error'));

+ 6 - 0
src/ORM/Association/BelongsToMany.php

@@ -804,6 +804,9 @@ class BelongsToMany extends Association
         $primary = (array)$target->primaryKey();
         $jointProperty = $this->_junctionProperty;
         foreach ($targetEntities as $k => $entity) {
+            if (!($entity instanceof EntityInterface)) {
+                continue;
+            }
             $key = array_values($entity->extract($primary));
             foreach ($present as $i => $data) {
                 if ($key === $data && !$entity->get($jointProperty)) {
@@ -873,6 +876,9 @@ class BelongsToMany extends Association
         $missing = [];
 
         foreach ($targetEntities as $entity) {
+            if (!($entity instanceof EntityInterface)) {
+                continue;
+            }
             $joint = $entity->get($jointProperty);
 
             if (!$joint || !($joint instanceof EntityInterface)) {

+ 15 - 8
src/ORM/Marshaller.php

@@ -237,6 +237,7 @@ class Marshaller
      * * associated: Associations listed here will be marshalled as well.
      * * fieldList: A whitelist of fields to be assigned to the entity. If not present,
      *   the accessible fields list in the entity will be used.
+     * * accessibleFields: A list of fields to allow or deny in entity accessible fields.
      *
      * @param array $data The data to hydrate.
      * @param array $options List of options
@@ -276,20 +277,26 @@ class Marshaller
         }
         $data = array_values($data);
 
-        // Accept [ [id => 1], [id = 2] ] style.
         $primaryKey = array_flip($assoc->target()->schema()->primaryKey());
-        if (array_intersect_key($primaryKey, current($data)) === $primaryKey) {
-            $primaryCount = count($primaryKey);
-            $query = $assoc->find();
-            foreach ($data as $row) {
+        $records = [];
+
+        foreach ($data as $row) {
+            if (array_intersect_key($primaryKey, $row) === $primaryKey) {
+                if (!isset($query)) {
+                    $primaryCount = count($primaryKey);
+                    $query = $assoc->find();
+                }
                 $keys = array_intersect_key($row, $primaryKey);
                 if (count($keys) === $primaryCount) {
                     $query->orWhere($keys);
                 }
+            } else {
+                $records[] = $this->one($row, $options);
             }
-            $records = $query->toArray();
-        } else {
-            $records = $this->many($data, $options);
+        }
+
+        if (isset($query)) {
+            $records = array_merge($records, $query->toArray());
         }
 
         $joint = $assoc->junction();

+ 1 - 1
src/TestSuite/Fixture/FixtureManager.php

@@ -191,7 +191,7 @@ class FixtureManager
      * @param bool $drop whether drop the fixture if it is already created or not
      * @return void
      */
-    protected function _setupTable(TestFixture $fixture, Connection $db, array $sources, $drop = true)
+    protected function _setupTable($fixture, $db, array $sources, $drop = true)
     {
         if (!empty($fixture->created) && in_array($db->configName(), $fixture->created)) {
             return;

+ 2 - 1
src/TestSuite/TestCase.php

@@ -19,6 +19,7 @@ use Cake\Datasource\ConnectionManager;
 use Cake\ORM\TableRegistry;
 use Cake\Routing\Router;
 use Cake\Utility\Inflector;
+use Exception;
 
 /**
  * Cake TestCase class
@@ -126,7 +127,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
     public function loadFixtures()
     {
         if (empty($this->fixtureManager)) {
-            throw new \Exception('No fixture manager to load the test fixture');
+            throw new Exception('No fixture manager to load the test fixture');
         }
         $args = func_get_args();
         foreach ($args as $class) {

+ 1 - 1
src/Utility/Hash.php

@@ -45,7 +45,7 @@ class Hash
      */
     public static function get(array $data, $path, $default = null)
     {
-        if (empty($data)) {
+        if (empty($data) || $path === null || $path === '') {
             return $default;
         }
 

+ 1 - 1
src/Validation/Validator.php

@@ -278,7 +278,7 @@ class Validator implements ArrayAccess, IteratorAggregate, Countable
      *          ->add('user_id', 'valid', ['rule' => 'numeric', 'message' => 'Invalid User'])
      *
      *      $validator->add('password', [
-     *          'size' => ['rule' => ['between', 8, 20]],
+     *          'size' => ['rule' => ['lengthBetween', 8, 20]],
      *          'hasSpecialCharacter' => ['rule' => 'validateSpecialchar', 'message' => 'not valid']
      *      ]);
      * ```

+ 14 - 0
src/View/Helper/SessionHelper.php

@@ -16,6 +16,7 @@ namespace Cake\View\Helper;
 
 use Cake\View\Helper;
 use Cake\View\StringTemplateTrait;
+use Cake\View\View;
 
 /**
  * Session Helper.
@@ -23,6 +24,7 @@ use Cake\View\StringTemplateTrait;
  * Session reading from the view.
  *
  * @link http://book.cakephp.org/3.0/en/views/helpers/session.html
+ * @deprecated 3.1.0 Use request->session() instead.
  */
 class SessionHelper extends Helper
 {
@@ -41,6 +43,18 @@ class SessionHelper extends Helper
     ];
 
     /**
+     *  Constructor
+     *
+     * @param \Cake\View\View $View The View this helper is being attached to.
+     * @param array $config Configuration settings for the helper.
+     */
+    public function __construct(View $View, array $config = [])
+    {
+        trigger_error('SessionHelper has been deprecated. Use request->session() instead.', E_USER_DEPRECATED);
+        parent::__construct($View, $config);
+    }
+
+    /**
      * Reads a session value for a key or returns values for all keys.
      *
      * In your view: `$this->Session->read('Controller.sessKey');`

+ 2 - 1
tests/Fixture/FixturizedTestCase.php

@@ -2,6 +2,7 @@
 namespace Cake\Test\Fixture;
 
 use Cake\TestSuite\TestCase;
+use Exception;
 
 /**
  * This class helps in testing the life-cycle of fixtures inside a CakeTestCase
@@ -64,6 +65,6 @@ class FixturizedTestCase extends TestCase
      */
     public function testThrowException()
     {
-        throw new \Exception();
+        throw new Exception();
     }
 }

+ 42 - 0
tests/TestCase/Collection/CollectionTest.php

@@ -1163,4 +1163,46 @@ class CollectionTest extends TestCase
 
         $this->assertEquals([1, 2, 3, 1, 2, 3], $collection->toList());
     }
+
+    /**
+     * Tests __debugInfo() or debug() usage
+     *
+     * @return void
+     */
+    public function testDebug()
+    {
+        $items = [1, 2, 3];
+
+        $collection = new Collection($items);
+
+        $result = $collection->__debugInfo();
+        $expected = [
+            'count' => 3,
+        ];
+        $this->assertSame($expected, $result);
+
+        // Calling it again will rewind
+        $result = $collection->__debugInfo();
+        $expected = [
+            'count' => 3,
+        ];
+        $this->assertSame($expected, $result);
+
+        // Make sure it also works with non rewindable iterators
+        $iterator = new NoRewindIterator(new ArrayIterator($items));
+        $collection = new Collection($iterator);
+
+        $result = $collection->__debugInfo();
+        $expected = [
+            'count' => 3,
+        ];
+        $this->assertSame($expected, $result);
+
+        // Calling it again will in this case not rewind
+        $result = $collection->__debugInfo();
+        $expected = [
+            'count' => 0,
+        ];
+        $this->assertSame($expected, $result);
+    }
 }

+ 2 - 2
tests/TestCase/Controller/Component/FlashComponentTest.php

@@ -18,10 +18,10 @@ use Cake\Controller\ComponentRegistry;
 use Cake\Controller\Component\FlashComponent;
 use Cake\Controller\Controller;
 use Cake\Core\Configure;
-use Cake\Event\Event;
 use Cake\Network\Request;
 use Cake\Network\Session;
 use Cake\TestSuite\TestCase;
+use Exception;
 
 /**
  * FlashComponentTest class
@@ -155,7 +155,7 @@ class FlashComponentTest extends TestCase
     {
         $this->assertNull($this->Session->read('Flash.flash'));
 
-        $this->Flash->set(new \Exception('This is a test message', 404));
+        $this->Flash->set(new Exception('This is a test message', 404));
         $expected = [
             [
                 'message' => 'This is a test message',

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

@@ -70,7 +70,7 @@ class TestController extends ControllerTestAppController
      *
      * @var array
      */
-    public $helpers = ['Session'];
+    public $helpers = ['Html'];
 
     /**
      * components property
@@ -549,7 +549,6 @@ class ControllerTest extends TestCase
 
         $expected = [
             'Html' => null,
-            'Session' => null
         ];
         $this->assertEquals($expected, $TestController->helpers);
 

+ 2 - 1
tests/TestCase/Core/InstanceConfigTraitTest.php

@@ -16,6 +16,7 @@ namespace Cake\Test\TestCase\Core;
 
 use Cake\Core\InstanceConfigTrait;
 use Cake\TestSuite\TestCase;
+use Exception;
 
 /**
  * TestInstanceConfig
@@ -68,7 +69,7 @@ class ReadOnlyTestInstanceConfig
      */
     protected function _configWrite($key, $value = null)
     {
-        throw new \Exception('This Instance is readonly');
+        throw new Exception('This Instance is readonly');
     }
 }
 

+ 9 - 8
tests/TestCase/Error/ExceptionRendererTest.php

@@ -18,13 +18,12 @@ use Cake\Controller\Component;
 use Cake\Controller\Controller;
 use Cake\Controller\Exception\MissingActionException;
 use Cake\Controller\Exception\MissingComponentException;
-use Cake\Core\App;
 use Cake\Core\Configure;
+use Cake\Core\Exception\Exception as CakeException;
 use Cake\Core\Exception\MissingPluginException;
 use Cake\Core\Plugin;
 use Cake\Datasource\Exception\MissingDatasourceConfigException;
 use Cake\Datasource\Exception\MissingDatasourceException;
-use Cake\Error;
 use Cake\Error\ExceptionRenderer;
 use Cake\Event\Event;
 use Cake\Event\EventManager;
@@ -40,6 +39,8 @@ use Cake\TestSuite\TestCase;
 use Cake\View\Exception\MissingHelperException;
 use Cake\View\Exception\MissingLayoutException;
 use Cake\View\Exception\MissingTemplateException;
+use Exception;
+use RuntimeException;
 
 /**
  * BlueberryComponent class
@@ -583,21 +584,21 @@ class ExceptionRendererTest extends TestCase
                 500
             ],
             [
-                new \Exception('boom'),
+                new Exception('boom'),
                 [
                     '/Internal Error/'
                 ],
                 500
             ],
             [
-                new \RuntimeException('another boom'),
+                new RuntimeException('another boom'),
                 [
                     '/Internal Error/'
                 ],
                 500
             ],
             [
-                new \Cake\Core\Exception\Exception('base class'),
+                new CakeException('base class'),
                 ['/Internal Error/'],
                 500
             ]
@@ -664,7 +665,7 @@ class ExceptionRendererTest extends TestCase
         $ExceptionRenderer->controller->response = $response;
         $ExceptionRenderer->render();
         sort($ExceptionRenderer->controller->helpers);
-        $this->assertEquals(['Form', 'Html', 'Session'], $ExceptionRenderer->controller->helpers);
+        $this->assertEquals(['Form', 'Html'], $ExceptionRenderer->controller->helpers);
     }
 
     /**
@@ -806,7 +807,7 @@ class ExceptionRendererTest extends TestCase
         Router::reload();
         $this->assertNull(Router::getRequest(false));
 
-        $exception = new \Exception('Terrible');
+        $exception = new Exception('Terrible');
         $ExceptionRenderer = new ExceptionRenderer($exception);
         $result = $ExceptionRenderer->render();
 
@@ -829,7 +830,7 @@ class ExceptionRendererTest extends TestCase
         $events->attach($listener, 'Controller.shutdown');
         $events->attach($listener, 'Dispatcher.afterDispatch');
 
-        $exception = new \Exception('Terrible');
+        $exception = new Exception('Terrible');
         $renderer = new ExceptionRenderer($exception);
         $renderer->render();
 

+ 2 - 4
tests/TestCase/Network/Email/EmailTest.php

@@ -14,16 +14,14 @@
  */
 namespace Cake\Test\TestCase\Network\Email;
 
-use Cake\Core\App;
 use Cake\Core\Configure;
 use Cake\Core\Plugin;
-use Cake\Filesystem\File;
 use Cake\Log\Log;
 use Cake\Network\Email\DebugTransport;
 use Cake\Network\Email\Email;
 use Cake\ORM\TableRegistry;
 use Cake\TestSuite\TestCase;
-use Cake\View\Exception\MissingTemplateException;
+use Exception;
 use SimpleXmlElement;
 
 /**
@@ -2623,7 +2621,7 @@ XML;
             ->viewVars([
                 'users' => TableRegistry::get('Users')->get(1, ['fields' => ['id', 'username']]),
                 'xml' => new SimpleXmlElement($xmlstr),
-                'exception' => new \Exception('test')
+                'exception' => new Exception('test')
             ])
             ->attachments([
                 'test.txt' => TEST_APP . 'config' . DS . 'empty.ini',

+ 1 - 1
tests/TestCase/ORM/Association/BelongsToManyTest.php

@@ -912,7 +912,7 @@ class BelongsToManyTest extends TestCase
      *
      * @return void
      */
-    public function testSaveAssociatedOnlyEntities()
+    public function testSaveAssociatedOnlyEntitiesAppend()
     {
         $connection = ConnectionManager::get('test');
         $mock = $this->getMock(

+ 1 - 0
tests/TestCase/ORM/CompositeKeysTest.php

@@ -229,6 +229,7 @@ class CompositeKeyTest extends TestCase
             'targetTable' => $tags,
             'propertyName' => 'tags',
             'through' => 'SiteArticlesTags',
+            'sort' => ['SiteTags.id' => 'asc'],
             'foreignKey' => ['article_id', 'site_id'],
             'targetForeignKey' => ['tag_id', 'site_id']
         ]);

+ 49 - 0
tests/TestCase/ORM/MarshallerTest.php

@@ -558,6 +558,55 @@ class MarshallerTest extends TestCase
     }
 
     /**
+     * Test belongsToMany association with mixed data array
+     *
+     * @return void
+     */
+    public function testBelongsToManyWithMixedData()
+    {
+        $data = [
+            'title' => 'My title',
+            'body' => 'My content',
+            'author_id' => 1,
+            'tags' => [
+                [
+                    'name' => 'tag4'
+                ],
+                [
+                    'name' => 'tag5'
+                ],
+                [
+                    'id' => 1
+                ]
+            ]
+        ];
+
+        $articles = TableRegistry::get('Articles');
+        $articles->belongsToMany('Tags');
+
+        $tags = TableRegistry::get('Tags');
+
+        $article = $articles->newEntity($data, [
+            'associated' => [
+                'Tags'
+            ]
+        ]);
+
+        $this->assertEquals($data['tags'][0]['name'], $article->tags[0]->name);
+        $this->assertEquals($data['tags'][1]['name'], $article->tags[1]->name);
+        $this->assertEquals($article->tags[2], $tags->get(1));
+
+        $this->assertEquals($article->tags[0]->isNew(), true);
+        $this->assertEquals($article->tags[1]->isNew(), true);
+        $this->assertEquals($article->tags[2]->isNew(), false);
+
+        $tagCount = $tags->find()->count();
+        $articles->save($article);
+
+        $this->assertEquals($tagCount + 2, $tags->find()->count());
+    }
+
+    /**
      * Test HasMany association with _ids attribute
      *
      * @return void

+ 19 - 3
tests/TestCase/ORM/TableTest.php

@@ -17,7 +17,7 @@ namespace Cake\Test\TestCase\ORM;
 use ArrayObject;
 use Cake\Core\Configure;
 use Cake\Core\Plugin;
-use Cake\Database\Expression\OrderByExpression;
+use Cake\Database\Exception;
 use Cake\Database\Expression\QueryExpression;
 use Cake\Database\TypeMap;
 use Cake\Datasource\ConnectionManager;
@@ -859,7 +859,7 @@ class TableTest extends TestCase
 
         $query->expects($this->once())
             ->method('execute')
-            ->will($this->throwException(new \Cake\Database\Exception('Not good')));
+            ->will($this->throwException(new Exception('Not good')));
 
         $table->updateAll(['username' => 'mark'], []);
     }
@@ -922,7 +922,7 @@ class TableTest extends TestCase
 
         $query->expects($this->once())
             ->method('execute')
-            ->will($this->throwException(new \Cake\Database\Exception('Not good')));
+            ->will($this->throwException(new Exception('Not good')));
 
         $table->deleteAll(['id >' => 4]);
     }
@@ -3171,6 +3171,22 @@ class TableTest extends TestCase
     }
 
     /**
+     * Test that belongsToMany ignores non-entity data.
+     *
+     * @return void
+     */
+    public function testSaveBelongsToManyIgnoreNonEntityData()
+    {
+        $articles = TableRegistry::get('Articles');
+        $article = $articles->get(1, ['contain' => ['Tags']]);
+        $article->tags = [
+            '_ids' => [2, 1]
+        ];
+        $result = $articles->save($article);
+        $this->assertSame($result, $article);
+    }
+
+    /**
      * Tests that saving a persisted and clean entity will is a no-op
      *
      * @group save

+ 2 - 4
tests/TestCase/TestSuite/TestFixtureTest.php

@@ -14,12 +14,10 @@
  */
 namespace Cake\Test\TestCase\TestSuite;
 
-use Cake\Core\Configure;
-use Cake\Datasource\ConnectionManager;
 use Cake\Log\Log;
 use Cake\TestSuite\Fixture\TestFixture;
 use Cake\TestSuite\TestCase;
-use Cake\Utility\ClassRegistry;
+use Exception;
 
 /**
  * ArticlesFixture class
@@ -251,7 +249,7 @@ class TestFixtureTest extends TestCase
         $table->expects($this->once())
             ->method('createSql')
             ->with($db)
-            ->will($this->throwException(new \Exception('oh noes')));
+            ->will($this->throwException(new Exception('oh noes')));
         $fixture->schema($table);
 
         $fixture->create($db);

+ 3 - 0
tests/TestCase/Utility/HashTest.php

@@ -210,6 +210,9 @@ class HashTest extends TestCase
         $result = Hash::get($data, '');
         $this->assertNull($result);
 
+        $result = Hash::get($data, null, '-');
+        $this->assertSame('-', $result);
+
         $result = Hash::get($data, '0.Article.title');
         $this->assertEquals('First Article', $result);
 

+ 0 - 117
tests/TestCase/View/Helper/SessionHelperTest.php

@@ -1,117 +0,0 @@
-<?php
-/**
- * SessionHelperTest file
- *
- * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
- * 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://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
- * @since         1.2.0
- * @license       http://www.opensource.org/licenses/mit-license.php MIT License
- */
-namespace Cake\Test\TestCase\View\Helper;
-
-use Cake\Controller\Controller;
-use Cake\Core\App;
-use Cake\Core\Plugin;
-use Cake\Network\Request;
-use Cake\Network\Session;
-use Cake\TestSuite\TestCase;
-use Cake\View\Helper\SessionHelper;
-use Cake\View\View;
-
-/**
- * SessionHelperTest class
- *
- */
-class SessionHelperTest extends TestCase
-{
-
-    /**
-     * setUp method
-     *
-     * @return void
-     */
-    public function setUp()
-    {
-        parent::setUp();
-        $this->View = new View();
-        $session = new Session();
-        $this->View->request = new Request(['session' => $session]);
-        $this->Session = new SessionHelper($this->View);
-
-        $session->write([
-            'test' => 'info',
-            'Flash' => [
-                'flash' => [
-                    'type' => 'info',
-                    'params' => [],
-                    'message' => 'This is a calling'
-                ],
-                'notification' => [
-                    'type' => 'info',
-                    'params' => [
-                        'title' => 'Notice!',
-                        'name' => 'Alert!',
-                        'element' => 'session_helper'
-                    ],
-                    'message' => 'This is a test of the emergency broadcasting system',
-                ],
-                'classy' => [
-                    'type' => 'success',
-                    'params' => ['class' => 'positive'],
-                    'message' => 'Recorded'
-                ],
-                'incomplete' => [
-                    'message' => 'A thing happened',
-                ]
-            ],
-            'Deeply' => ['nested' => ['key' => 'value']],
-        ]);
-    }
-
-    /**
-     * tearDown method
-     *
-     * @return void
-     */
-    public function tearDown()
-    {
-        $_SESSION = [];
-        unset($this->View, $this->Session);
-        Plugin::unload();
-        parent::tearDown();
-    }
-
-    /**
-     * testRead method
-     *
-     * @return void
-     */
-    public function testRead()
-    {
-        $result = $this->Session->read('Deeply.nested.key');
-        $this->assertEquals('value', $result);
-
-        $result = $this->Session->read('test');
-        $this->assertEquals('info', $result);
-    }
-
-    /**
-     * testCheck method
-     *
-     * @return void
-     */
-    public function testCheck()
-    {
-        $this->assertTrue($this->Session->check('test'));
-        $this->assertTrue($this->Session->check('Flash.flash'));
-        $this->assertFalse($this->Session->check('Does.not.exist'));
-        $this->assertFalse($this->Session->check('Nope'));
-    }
-}

+ 4 - 6
tests/TestCase/View/ViewTest.php

@@ -1169,7 +1169,6 @@ class ViewTest extends TestCase
     public function testBeforeLayout()
     {
         $this->PostsController->helpers = [
-            'Session',
             'TestBeforeAfter' => ['className' => __NAMESPACE__ . '\TestBeforeAfterHelper'],
             'Html'
         ];
@@ -1186,7 +1185,6 @@ class ViewTest extends TestCase
     public function testAfterLayout()
     {
         $this->PostsController->helpers = [
-            'Session',
             'TestBeforeAfter' => ['className' => __NAMESPACE__ . '\TestBeforeAfterHelper'],
             'Html'
         ];
@@ -1207,7 +1205,7 @@ class ViewTest extends TestCase
      */
     public function testRenderLoadHelper()
     {
-        $this->PostsController->helpers = ['Session', 'Form', 'Number'];
+        $this->PostsController->helpers = ['Form', 'Number'];
         $View = $this->PostsController->createView('Cake\Test\TestCase\View\TestView');
 
         $result = $View->render('index', false);
@@ -1215,7 +1213,7 @@ class ViewTest extends TestCase
 
         $attached = $View->helpers()->loaded();
         // HtmlHelper is loaded in TestView::initialize()
-        $this->assertEquals(['Html', 'Session', 'Form', 'Number'], $attached);
+        $this->assertEquals(['Html', 'Form', 'Number'], $attached);
 
         $this->PostsController->helpers = ['Html', 'Form', 'Number', 'TestPlugin.PluggedHelper'];
         $View = $this->PostsController->createView('Cake\Test\TestCase\View\TestView');
@@ -1249,7 +1247,7 @@ class ViewTest extends TestCase
 
         $this->assertNull($View->render(false, 'ajax2'));
 
-        $this->PostsController->helpers = ['Session', 'Html'];
+        $this->PostsController->helpers = ['Html'];
         $this->PostsController->request->params['action'] = 'index';
         Configure::write('Cache.check', true);
 
@@ -1302,7 +1300,7 @@ class ViewTest extends TestCase
     public function testViewVarOverwritingLocalHelperVar()
     {
         $Controller = new ViewPostsController();
-        $Controller->helpers = ['Session', 'Html'];
+        $Controller->helpers = ['Html'];
         $Controller->set('html', 'I am some test html');
         $View = $Controller->createView();
         $result = $View->render('helper_overwrite', false);

+ 1 - 1
tests/test_app/TestApp/Controller/PagesController.php

@@ -38,7 +38,7 @@ class PagesController extends AppController
      *
      * @var array
      */
-    public $helpers = ['Html', 'Session'];
+    public $helpers = ['Html'];
 
     /**
      * Displays a view

+ 0 - 1
tests/test_app/TestApp/Controller/TestAppsErrorController.php

@@ -8,7 +8,6 @@ class TestAppsErrorController extends ErrorController
 
     public $helpers = [
         'Html',
-        'Session',
         'Form',
         'Banana',
     ];