浏览代码

Hack and fixed tests for postgres.

dereuromark 9 年之前
父节点
当前提交
a988d7d79c

+ 0 - 3
.travis.yml

@@ -25,9 +25,6 @@ matrix:
     - php: 7.0
       env: CODECOVERAGE=1 DEFAULT=0
 
-  allow_failures:
-    - env: DB=pgsql db_class='Cake\Database\Driver\Postgres' db_dsn='pgsql:host=127.0.0.1;dbname=cakephp_test' db_database="cakephp_test" db_username='postgres' db_password=''
-
 before_script:
   - composer self-update
   - composer install --prefer-dist --no-interaction

+ 8 - 0
src/Model/Behavior/BitmaskedBehavior.php

@@ -264,6 +264,14 @@ class BitmaskedBehavior extends Behavior {
 		$field = $this->_config['field'];
 		$contain = $contain ? ' & ? = ?' : ' & ? != ?';
 		$contain = Text::insert($contain, [$bitmask, $bitmask]);
+
+		// Hack for Postgres for now
+		$connection = $this->_table->connection();
+		$config = $connection->config();
+		if ((strpos($config['driver'], 'Postgres') !== false)) {
+			return ['("' . $this->_table->alias() . '"."' . $field . '"' . $contain . ')'];
+		}
+
 		return ['(' . $this->_table->alias() . '.' . $field . $contain . ')'];
 	}
 

+ 1 - 1
src/Model/Behavior/ResetBehavior.php

@@ -87,7 +87,7 @@ class ResetBehavior extends Behavior {
 			'page' => 1,
 			'limit' => $this->_config['limit'],
 			'fields' => [],
-			'order' => $this->_table->alias() . '.' . $this->_table->primaryKey() . ' ASC',
+			'order' => [$this->_table->alias() . '.' . $this->_table->primaryKey() => 'ASC'],
 			'conditions' => $this->_config['scope'],
 		];
 		if (!empty($this->_config['fields'])) {

+ 11 - 15
tests/Fixture/RolesFixture.php

@@ -16,8 +16,8 @@ class RolesFixture extends TestFixture {
 	 */
 	public $fields = [
 		'id' => ['type' => 'integer'],
-		'name' => ['type' => 'string', 'null' => false, 'length' => 64, 'collate' => 'utf8_unicode_ci', 'comment' => '', 'charset' => 'utf8'],
-		'alias' => ['type' => 'string', 'null' => true, 'default' => null, 'length' => 20, 'collate' => 'utf8_unicode_ci', 'comment' => '', 'charset' => 'utf8'],
+		'name' => ['type' => 'string', 'null' => false, 'length' => 64, 'comment' => ''],
+		'alias' => ['type' => 'string', 'null' => true, 'default' => null, 'length' => 20, 'comment' => ''],
 		'default_role' => ['type' => 'boolean', 'null' => false, 'default' => false, 'collate' => null, 'comment' => 'set at register'],
 		'created' => ['type' => 'datetime', 'null' => true, 'default' => null, 'collate' => null, 'comment' => ''],
 		'modified' => ['type' => 'datetime', 'null' => true, 'default' => null, 'collate' => null, 'comment' => ''],
@@ -33,7 +33,15 @@ class RolesFixture extends TestFixture {
 	 */
 	public $records = [
 		[
-			'id' => '2',
+			'name' => 'Super-Admin',
+			'alias' => 'superadmin',
+			'default_role' => 0,
+			'created' => '2010-01-07 03:36:33',
+			'modified' => '2010-01-07 03:36:33',
+			'sort' => '7',
+			'active' => 1
+		],
+		[
 			'name' => 'Admin',
 			'alias' => 'admin',
 			'default_role' => 0,
@@ -43,7 +51,6 @@ class RolesFixture extends TestFixture {
 			'active' => 1
 		],
 		[
-			'id' => '4',
 			'name' => 'User',
 			'alias' => 'user',
 			'default_role' => 1,
@@ -53,7 +60,6 @@ class RolesFixture extends TestFixture {
 			'active' => 1
 		],
 		[
-			'id' => '6',
 			'name' => 'Partner',
 			'alias' => 'partner',
 			'default_role' => 0,
@@ -62,16 +68,6 @@ class RolesFixture extends TestFixture {
 			'sort' => '0',
 			'active' => 1
 		],
-		[
-			'id' => '1',
-			'name' => 'Super-Admin',
-			'alias' => 'superadmin',
-			'default_role' => 0,
-			'created' => '2010-01-07 03:36:33',
-			'modified' => '2010-01-07 03:36:33',
-			'sort' => '7',
-			'active' => 1
-		],
 	];
 
 }

+ 2 - 2
tests/Fixture/StoriesFixture.php

@@ -16,8 +16,8 @@ class StoriesFixture extends TestFixture {
 	 */
 	public $fields = [
 		'id' => ['type' => 'integer'],
-		'title' => ['type' => 'string', 'null' => false, 'length' => 64, 'collate' => 'utf8_unicode_ci', 'comment' => '', 'charset' => 'utf8'],
-		'slug' => ['type' => 'string', 'null' => true, 'default' => null, 'length' => 20, 'collate' => 'utf8_unicode_ci', 'comment' => '', 'charset' => 'utf8'],
+		'title' => ['type' => 'string', 'null' => false, 'length' => 64, 'comment' => ''],
+		'slug' => ['type' => 'string', 'null' => true, 'default' => null, 'length' => 20, 'comment' => ''],
 		'created' => ['type' => 'datetime', 'null' => true, 'default' => null, 'collate' => null, 'comment' => ''],
 		'modified' => ['type' => 'datetime', 'null' => true, 'default' => null, 'collate' => null, 'comment' => ''],
 		'sort' => ['type' => 'integer', 'null' => false, 'default' => '0', 'length' => 10, 'collate' => null, 'comment' => ''],

+ 4 - 14
tests/Fixture/TokensFixture.php

@@ -16,10 +16,10 @@ class TokensFixture extends TestFixture {
 	 */
 	public $fields = [
 		'id' => ['type' => 'integer', 'null' => false, 'default' => null, 'length' => 10],
-		'user_id' => ['type' => 'string', 'null' => true, 'length' => 36, 'collate' => 'utf8_unicode_ci', 'comment' => '', 'charset' => 'utf8'],
-		'type' => ['type' => 'string', 'null' => true, 'default' => null, 'length' => 10, 'collate' => 'utf8_unicode_ci', 'comment' => 'e.g.:activate,reactivate', 'charset' => 'utf8'],
-		'key' => ['type' => 'string', 'null' => true, 'default' => null, 'length' => 60, 'collate' => 'utf8_unicode_ci', 'comment' => '', 'charset' => 'utf8'],
-		'content' => ['type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_unicode_ci', 'comment' => 'can transport some information', 'charset' => 'utf8'],
+		'user_id' => ['type' => 'string', 'null' => true, 'length' => 36, 'comment' => ''],
+		'type' => ['type' => 'string', 'null' => true, 'default' => null, 'length' => 10, 'comment' => 'e.g.:activate,reactivate'],
+		'key' => ['type' => 'string', 'null' => true, 'default' => null, 'length' => 60, 'comment' => ''],
+		'content' => ['type' => 'string', 'null' => true, 'default' => null, 'comment' => 'can transport some information'],
 		'used' => ['type' => 'integer', 'null' => false, 'default' => '0', 'collate' => null, 'comment' => ''],
 		'created' => ['type' => 'datetime', 'null' => true, 'default' => null, 'collate' => null, 'comment' => ''],
 		'modified' => ['type' => 'datetime', 'null' => true, 'default' => null, 'collate' => null, 'comment' => ''],
@@ -33,7 +33,6 @@ class TokensFixture extends TestFixture {
 	 */
 	public $records = [
 		[
-			'id' => '77',
 			'user_id' => '1',
 			'type' => 'qlogin',
 			'key' => '7k8qdcizigtudvxn2v9zep',
@@ -43,7 +42,6 @@ class TokensFixture extends TestFixture {
 			'modified' => '2011-08-02 18:00:41'
 		],
 		[
-			'id' => '78',
 			'user_id' => '2',
 			'type' => 'qlogin',
 			'key' => '23e32tpkcmdn8x9j8n0n00',
@@ -53,7 +51,6 @@ class TokensFixture extends TestFixture {
 			'modified' => '2011-08-02 18:00:41'
 		],
 		[
-			'id' => '79',
 			'user_id' => '1',
 			'type' => 'qlogin',
 			'key' => '3mpzed7eoewsjvyvg4vy35',
@@ -63,7 +60,6 @@ class TokensFixture extends TestFixture {
 			'modified' => '2011-08-02 18:00:41'
 		],
 		[
-			'id' => '80',
 			'user_id' => '2',
 			'type' => 'qlogin',
 			'key' => 'af8ww4y7jxzq5n6npmjpxx',
@@ -73,7 +69,6 @@ class TokensFixture extends TestFixture {
 			'modified' => '2011-08-02 18:00:41'
 		],
 		[
-			'id' => '81',
 			'user_id' => '1',
 			'type' => 'qlogin',
 			'key' => '2s7i3zjw0rn009j4no552b',
@@ -83,7 +78,6 @@ class TokensFixture extends TestFixture {
 			'modified' => '2011-08-02 18:01:16'
 		],
 		[
-			'id' => '82',
 			'user_id' => '2',
 			'type' => 'qlogin',
 			'key' => 'tro596dig63cay0ps09vre',
@@ -93,7 +87,6 @@ class TokensFixture extends TestFixture {
 			'modified' => '2011-08-02 18:01:16'
 		],
 		[
-			'id' => '83',
 			'user_id' => '1',
 			'type' => 'qlogin',
 			'key' => 'penfangwc40x550wwvgfmu',
@@ -103,7 +96,6 @@ class TokensFixture extends TestFixture {
 			'modified' => '2011-08-02 18:01:16'
 		],
 		[
-			'id' => '84',
 			'user_id' => '2',
 			'type' => 'qlogin',
 			'key' => '2y7m5srasm3ozej0izxbhe',
@@ -113,7 +105,6 @@ class TokensFixture extends TestFixture {
 			'modified' => '2011-08-02 18:01:16'
 		],
 		[
-			'id' => '85',
 			'user_id' => '1',
 			'type' => 'qlogin',
 			'key' => '5c6dp2w54ynxii2xo3c50m',
@@ -123,7 +114,6 @@ class TokensFixture extends TestFixture {
 			'modified' => '2011-08-02 18:01:54'
 		],
 		[
-			'id' => '86',
 			'user_id' => '2',
 			'type' => 'qlogin',
 			'key' => 'fr6a0d4waue2v6hmqeyek5',

+ 22 - 19
tests/TestCase/Model/Behavior/BitmaskedBehaviorTest.php

@@ -17,10 +17,13 @@ class BitmaskedBehaviorTest extends TestCase {
 	];
 
 	/**
-	 * @var \Tools\Model\Table\Table
+	 * @var \Tools\Model\Table\Table|\Tools\Model\Behavior\BitmaskedBehavior
 	 */
 	public $Comments;
 
+	/**
+	 * @return void
+	 */
 	public function setUp() {
 		parent::setUp();
 
@@ -31,8 +34,6 @@ class BitmaskedBehaviorTest extends TestCase {
 	}
 
 	/**
-	 * BitmaskedBehaviorTest::testEncodeBitmask()
-	 *
 	 * @return void
 	 */
 	public function testEncodeBitmask() {
@@ -42,8 +43,6 @@ class BitmaskedBehaviorTest extends TestCase {
 	}
 
 	/**
-	 * BitmaskedBehaviorTest::testDecodeBitmask()
-	 *
 	 * @return void
 	 */
 	public function testDecodeBitmask() {
@@ -53,8 +52,6 @@ class BitmaskedBehaviorTest extends TestCase {
 	}
 
 	/**
-	 * BitmaskedBehaviorTest::testFind()
-	 *
 	 * @return void
 	 */
 	public function testFind() {
@@ -65,8 +62,6 @@ class BitmaskedBehaviorTest extends TestCase {
 	}
 
 	/**
-	 * BitmaskedBehaviorTest::testSave()
-	 *
 	 * @return void
 	 */
 	public function testSaveBasic() {
@@ -180,8 +175,6 @@ class BitmaskedBehaviorTest extends TestCase {
 	}
 
 	/**
-	 * BitmaskedBehaviorTest::testIs()
-	 *
 	 * @return void
 	 */
 	public function testIs() {
@@ -191,8 +184,6 @@ class BitmaskedBehaviorTest extends TestCase {
 	}
 
 	/**
-	 * BitmaskedBehaviorTest::testIsNot()
-	 *
 	 * @return void
 	 */
 	public function testIsNot() {
@@ -202,13 +193,17 @@ class BitmaskedBehaviorTest extends TestCase {
 	}
 
 	/**
-	 * BitmaskedBehaviorTest::testContains()
-	 *
 	 * @return void
 	 */
 	public function testContains() {
+		$config = $this->Comments->connection()->config();
+		$isPostgres = strpos($config['driver'], 'Postgres') !== false;
+
 		$res = $this->Comments->containsBit(BitmaskedComment::STATUS_PUBLISHED);
 		$expected = ['(BitmaskedComments.status & 2 = 2)'];
+		if ($isPostgres) {
+			$expected = ['("BitmaskedComments"."status" & 2 = 2)'];
+		}
 		$this->assertEquals($expected, $res);
 
 		$conditions = $res;
@@ -217,8 +212,10 @@ class BitmaskedBehaviorTest extends TestCase {
 
 		// multiple (AND)
 		$res = $this->Comments->containsBit([BitmaskedComment::STATUS_PUBLISHED, BitmaskedComment::STATUS_ACTIVE]);
-
 		$expected = ['(BitmaskedComments.status & 3 = 3)'];
+		if ($isPostgres) {
+			$expected = ['("BitmaskedComments"."status" & 3 = 3)'];
+		}
 		$this->assertEquals($expected, $res);
 
 		$conditions = $res;
@@ -227,13 +224,17 @@ class BitmaskedBehaviorTest extends TestCase {
 	}
 
 	/**
-	 * BitmaskedBehaviorTest::testNotContains()
-	 *
 	 * @return void
 	 */
 	public function testNotContains() {
+		$config = $this->Comments->connection()->config();
+		$isPostgres = strpos($config['driver'], 'Postgres') !== false;
+
 		$res = $this->Comments->containsNotBit(BitmaskedComment::STATUS_PUBLISHED);
 		$expected = ['(BitmaskedComments.status & 2 != 2)'];
+		if ($isPostgres) {
+			$expected = ['("BitmaskedComments"."status" & 2 != 2)'];
+		}
 		$this->assertEquals($expected, $res);
 
 		$conditions = $res;
@@ -242,8 +243,10 @@ class BitmaskedBehaviorTest extends TestCase {
 
 		// multiple (AND)
 		$res = $this->Comments->containsNotBit([BitmaskedComment::STATUS_PUBLISHED, BitmaskedComment::STATUS_ACTIVE]);
-
 		$expected = ['(BitmaskedComments.status & 3 != 3)'];
+		if ($isPostgres) {
+			$expected = ['("BitmaskedComments"."status" & 3 != 3)'];
+		}
 		$this->assertEquals($expected, $res);
 
 		$conditions = $res;

+ 35 - 55
tests/TestCase/Model/Behavior/PasswordableBehaviorTest.php

@@ -34,16 +34,6 @@ class PasswordableBehaviorTest extends TestCase {
 		$this->Users = TableRegistry::get('ToolsUsers');
 
 		$this->hasher = PasswordHasherFactory::build('Default');
-		$user = $this->Users->newEntity();
-		$data = [
-			'id' => '5',
-			'name' => 'admin',
-			'password' => $this->hasher->hash('somepwd'),
-			'role_id' => '1'
-		];
-		$this->Users->patchEntity($user, $data);
-		$result = $this->Users->save($user);
-		$this->assertTrue((bool)$result);
 
 		Router::setRequestInfo(new Request());
 	}
@@ -222,6 +212,17 @@ class PasswordableBehaviorTest extends TestCase {
 	 * @return void
 	 */
 	public function testNotSame() {
+		$user = $this->Users->newEntity();
+		$data = [
+			'name' => 'admin',
+			'password' => $this->hasher->hash('somepwd'),
+			'role_id' => '1'
+		];
+		$this->Users->patchEntity($user, $data);
+		$result = $this->Users->save($user);
+		$this->assertTrue((bool)$result);
+		$userCopy = clone($user);
+
 		$this->Users->addBehavior('Tools.Passwordable', [
 			'formField' => 'passw',
 			'formFieldRepeat' => 'passw_repeat',
@@ -229,21 +230,19 @@ class PasswordableBehaviorTest extends TestCase {
 			'allowSame' => false,
 			'current' => true,
 		]);
-		$user = $this->Users->newEntity();
+
+		$user = clone($userCopy);
 		$data = [
-			'id' => '5',
 			'passw_current' => 'something',
 			'passw' => 'somepwd',
 			'passw_repeat' => 'somepwd'
 		];
 		$this->Users->patchEntity($user, $data);
 		$is = $this->Users->save($user);
-		//debug($user->errors());
 		$this->assertFalse($is);
 
-		$user = $this->Users->newEntity([], ['markNew' => false]);
+		$user = clone($userCopy);
 		$data = [
-			'id' => '5',
 			'passw_current' => 'somepwd',
 			'passw' => 'newpwd',
 			'passw_repeat' => 'newpwd'
@@ -273,11 +272,11 @@ class PasswordableBehaviorTest extends TestCase {
 		$this->Users->patchEntity($user, $data);
 		$is = $this->Users->save($user);
 		$this->assertTrue((bool)$is);
-		$id = $is['id'];
+		$userCopy = clone($user);
+		$uid = $user->id;
 
-		$user = $this->Users->newEntity([], ['markNew' => false]);
+		$user = clone($userCopy);
 		$data = [
-			'id' => $id,
 			'passw' => 'somepwd',
 			'passw_repeat' => 'somepwd'
 		];
@@ -285,9 +284,8 @@ class PasswordableBehaviorTest extends TestCase {
 		$is = $this->Users->save($user);
 		$this->assertFalse((bool)$is);
 
-		$user = $this->Users->newEntity([], ['markNew' => false]);
+		$user = clone($userCopy);
 		$data = [
-			'id' => $id,
 			'passw' => 'newpwd',
 			'passw_repeat' => 'newpwd'
 		];
@@ -315,11 +313,10 @@ class PasswordableBehaviorTest extends TestCase {
 		$this->Users->patchEntity($user, $data);
 		$is = $this->Users->save($user);
 		$this->assertTrue((bool)$is);
-		$id = $is['id'];
+		$userCopy = clone($user);
 
-		$user = $this->Users->newEntity([], ['markNew' => false]);
+		$user = clone($userCopy);
 		$data = [
-			'id' => $id,
 			'passw' => '',
 			'passw_repeat' => ''
 		];
@@ -328,20 +325,17 @@ class PasswordableBehaviorTest extends TestCase {
 		$this->assertTrue((bool)$is);
 		//debug($user->errors());
 
-		$user = $this->Users->newEntity([], ['markNew' => false]);
+		$user = clone($userCopy);
 		$data = [
-			'id' => $id,
 			'passw' => 'somepwd2',
 			'passw_repeat' => ''
 		];
 		$this->Users->patchEntity($user, $data);
 		$is = $this->Users->save($user);
 		$this->assertFalse((bool)$is);
-		//debug($user->errors());
 
-		$user = $this->Users->newEntity([], ['markNew' => false]);
+		$user = clone($userCopy);
 		$data = [
-			'id' => $id,
 			'passw' => 'somepwd2',
 			'passw_repeat' => 'somepwd2'
 		];
@@ -364,25 +358,23 @@ class PasswordableBehaviorTest extends TestCase {
 		$this->Users->patchEntity($user, $data);
 		$result = $this->Users->save($user);
 		$this->assertTrue(!empty($result));
-		$uid = (string)$user->id;
+		$userCopy = clone($user);
+		$uid = $user->id;
 
 		$this->Users->removeBehavior('Passwordable');
 		$this->Users->addBehavior('Tools.Passwordable', ['current' => true]);
-		$user = $this->Users->newEntity([], ['markNew' => false]);
+		$user = clone($userCopy);
 		$data = [
-			'id' => $uid,
 			'pwd' => '123456',
 			'pwd_repeat' => '12345678',
-			//'pwd_current' => '',
 		];
 		$this->Users->patchEntity($user, $data);
 		$this->assertTrue($this->Users->behaviors()->has('Passwordable'));
 		$is = $this->Users->save($user);
 		$this->assertFalse($is);
 
-		$user = $this->Users->newEntity([], ['markNew' => false]);
+		$user = clone($userCopy);
 		$data = [
-			'id' => $uid,
 			'pwd_current' => 'somepwdx',
 			'pwd' => '123456',
 			'pwd_repeat' => '123456'
@@ -391,9 +383,8 @@ class PasswordableBehaviorTest extends TestCase {
 		$is = $this->Users->save($user);
 		$this->assertFalse($is);
 
-		$user = $this->Users->newEntity([], ['markNew' => false]);
+		$user = clone($userCopy);
 		$data = [
-			'id' => $uid,
 			'name' => 'Yeah',
 			'pwd_current' => 'somepwd',
 			'pwd' => '123456',
@@ -408,8 +399,6 @@ class PasswordableBehaviorTest extends TestCase {
 		$is = $this->Users->save($user, $options);
 		$this->assertTrue(!empty($is));
 
-		//$this->skipIf(true, 'FIXME: whitelisting fieldList');
-
 		$user = $this->Users->get($uid);
 		// The password is updated, the name not
 		$this->assertSame($is['password'], $user['password']);
@@ -418,9 +407,8 @@ class PasswordableBehaviorTest extends TestCase {
 		// Proof that we manually need to add pwd, pwd_repeat etc due to a bug in CakePHP<=2.4 allowing behaviors to only modify saving,
 		// not validating of additional whitelist fields. Validation for those will be just skipped, no matter what the behavior tries
 		// to set.
-		$user = $this->Users->newEntity([], ['markNew' => false]);
+		$user = clone($userCopy);
 		$data = [
-			'id' => $uid,
 			'name' => 'Yeah',
 			'pwd_current' => '123', // Obviously wrong
 			'pwd' => 'some', // Too short
@@ -463,25 +451,22 @@ class PasswordableBehaviorTest extends TestCase {
 		$this->Users->patchEntity($user, $data);
 		$result = $this->Users->save($user);
 		$this->assertTrue((bool)$result);
-		$uid = (string)$user->id;
+		$userCopy = clone($user);
 
 		$this->Users->removeBehavior('Passwordable');
 		$this->Users->addBehavior('Tools.Passwordable', ['current' => true]);
-		$user = $this->Users->newEntity();
+		$user = clone($userCopy);
 		$data = [
-			'id' => $uid,
 			'pwd' => '123456',
 			'pwd_repeat' => '12345678',
-			//'pwd_current' => '',
 		];
 		$this->Users->patchEntity($user, $data);
 		$this->assertTrue($this->Users->behaviors()->has('Passwordable'));
 		$is = $this->Users->save($user);
 		$this->assertFalse($is);
 
-		$user = $this->Users->newEntity();
+		$user = clone($userCopy);
 		$data = [
-			'id' => $uid,
 			'pwd_current' => 'somepwdx',
 			'pwd' => '123456',
 			'pwd_repeat' => '123456'
@@ -490,9 +475,8 @@ class PasswordableBehaviorTest extends TestCase {
 		$is = $this->Users->save($user);
 		$this->assertFalse($is);
 
-		$user = $this->Users->newEntity();
+		$user = clone($userCopy);
 		$data = [
-			'id' => $uid,
 			'pwd_current' => 'somepwd',
 			'pwd' => '123456',
 			'pwd_repeat' => '123456'
@@ -522,15 +506,14 @@ class PasswordableBehaviorTest extends TestCase {
 		$this->Users->patchEntity($user, $data);
 		$result = $this->Users->save($user);
 		$this->assertTrue((bool)$result);
+		$userCopy = clone($user);
 		$uid = (string)$user->id;
 
 		$this->Users->removeBehavior('Passwordable');
 		$this->Users->addBehavior('Tools.Passwordable', ['current' => true]);
 
 		// Without the current password it will not continue
-		$user = $this->Users->newEntity();
 		$data = [
-			'id' => $uid,
 			'pwd' => '123456',
 			'pwd_repeat' => '12345678',
 		];
@@ -540,9 +523,8 @@ class PasswordableBehaviorTest extends TestCase {
 		$this->assertFalse($result);
 
 		// Without the correct current password it will not continue
-		$user = $this->Users->newEntity();
+		$user = clone($userCopy);
 		$data = [
-			'id' => $uid,
 			'pwd_current' => 'somepwdx',
 			'pwd' => '123456',
 			'pwd_repeat' => '123456'
@@ -552,9 +534,8 @@ class PasswordableBehaviorTest extends TestCase {
 		$this->assertFalse($result);
 
 		// Now it will
-		$user = $this->Users->newEntity();
+		$user = clone($userCopy);
 		$data = [
-			'id' => $uid,
 			'pwd_current' => 'somepwd',
 			'pwd' => '123456',
 			'pwd_repeat' => '123456'
@@ -670,7 +651,6 @@ class PasswordableBehaviorTest extends TestCase {
 		$hash = $user['password'];
 
 		$data = [
-			'id' => $uid,
 			'pwd' => '1234'
 		];
 		$this->Users->patchEntity($user, $data, ['validate' => false]);

+ 10 - 9
tests/TestCase/Shell/InflectShellTest.php

@@ -3,6 +3,7 @@
 namespace Tools\Test\TestCase\Shell;
 
 use Cake\Console\ConsoleIo;
+use Tools\Shell\InflectShell;
 use Tools\TestSuite\ConsoleOutput;
 use Tools\TestSuite\TestCase;
 
@@ -11,8 +12,11 @@ use Tools\TestSuite\TestCase;
 class InflectShellTest extends TestCase {
 
 	/**
-	 * setUp method
-	 *
+	 * @var \Tools\Shell\InflectShell
+	 */
+	public $Shell;
+
+	/**
 	 * @return void
 	 */
 	public function setUp() {
@@ -22,16 +26,13 @@ class InflectShellTest extends TestCase {
 		$this->err = new ConsoleOutput();
 		$io = new ConsoleIo($this->out, $this->err);
 
-		$this->Shell = $this->getMock(
-			'Tools\Shell\InflectShell',
-			['in', '_stop'],
-			[$io]
-		);
+		$this->Shell = $this->getMockBuilder(InflectShell::class)
+			->setMethods(['in', '_stop'])
+			->setConstructorArgs([$io])
+			->getMock();
 	}
 
 	/**
-	 * tearDown
-	 *
 	 * @return void
 	 */
 	public function tearDown() {