Browse Source

Fix tests.

mscherer 6 years ago
parent
commit
3cd4f79cf7

+ 25 - 2
src/Database/Type/ArrayType.php

@@ -2,12 +2,13 @@
 
 namespace Tools\Database\Type;
 
-use Cake\Database\Type;
+use Cake\Database\Driver;
+use Cake\Database\Type\BaseType;
 
 /**
  * Do not convert input on marshal().
  */
-class ArrayType extends Type {
+class ArrayType extends BaseType {
 
 	/**
 	 * @param mixed $value
@@ -17,4 +18,26 @@ class ArrayType extends Type {
 		return $value;
 	}
 
+	/**
+	 * Casts given value from a PHP type to one acceptable by a database.
+	 *
+	 * @param mixed $value Value to be converted to a database equivalent.
+	 * @param \Cake\Database\Driver $driver Object from which database preferences and configuration will be extracted.
+	 * @return mixed Given PHP type casted to one acceptable by a database.
+	 */
+	public function toDatabase($value, Driver $driver) {
+		return $value;
+	}
+
+	/**
+	 * Casts given value from a database type to a PHP equivalent.
+	 *
+	 * @param mixed $value Value to be converted to PHP equivalent
+	 * @param \Cake\Database\Driver $driver Object from which database preferences and configuration will be extracted
+	 * @return mixed Given value casted from a database to a PHP equivalent.
+	 */
+	public function toPHP($value, Driver $driver) {
+		return $value;
+	}
+
 }

+ 1 - 0
src/Error/ErrorHandler.php

@@ -4,6 +4,7 @@ namespace Tools\Error;
 
 use Cake\Error\ErrorHandler as CoreErrorHandler;
 use Cake\Log\Log;
+use Throwable;
 
 /**
  * Custom ErrorHandler to not mix the 404 exceptions with the rest of "real" errors in the error.log file.

+ 2 - 2
src/Model/Behavior/BitmaskedBehavior.php

@@ -250,7 +250,7 @@ class BitmaskedBehavior extends Behavior {
 				return $comparison;
 			}
 
-			$comparison->setValue($this->encodeBitmask($comparison->getValue()));
+			$comparison->setValue((array)$this->encodeBitmask($comparison->getValue()));
 			if ($field !== $mappedField) {
 				$comparison->setField($field);
 			}
@@ -372,7 +372,7 @@ class BitmaskedBehavior extends Behavior {
 		}
 
 		$contain = $contain ? ' & ? = ?' : ' & ? != ?';
-		$contain = Text::insert($contain, [$bitmask, $bitmask]);
+		$contain = Text::insert($contain, [(string)$bitmask, (string)$bitmask]);
 
 		// Hack for Postgres for now
 		$connection = $this->_table->getConnection();

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

@@ -41,7 +41,6 @@ use RuntimeException;
  *
  * @author Mark Scherer
  * @license MIT
- * @version 1.0
  */
 class ResetBehavior extends Behavior {
 
@@ -121,7 +120,7 @@ class ResetBehavior extends Behavior {
 		$params += $defaults;
 
 		$conditions = $params['conditions'];
-		$count = $this->_table->find('count', compact('conditions'));
+		$count = $this->_table->find()->where($conditions)->count();
 		$max = (int)ini_get('max_execution_time');
 		if ($max) {
 			set_time_limit(max($max, $count));

+ 4 - 4
src/Model/Table/TokensTable.php

@@ -205,11 +205,11 @@ class TokensTable extends Table {
 	 */
 	public function stats() {
 		$keys = [];
-		$keys['unused_valid'] = $this->find('count', ['conditions' => [$this->getAlias() . '.used' => 0, $this->getAlias() . '.created >=' => date(FORMAT_DB_DATETIME, time() - $this->validity)]]);
-		$keys['used_valid'] = $this->find('count', ['conditions' => [$this->getAlias() . '.used' => 1, $this->getAlias() . '.created >=' => date(FORMAT_DB_DATETIME, time() - $this->validity)]]);
+		$keys['unused_valid'] = $this->find()->where([$this->getAlias() . '.used' => 0, $this->getAlias() . '.created >=' => date(FORMAT_DB_DATETIME, time() - $this->validity)])->count();
+		$keys['used_valid'] = $this->find()->where([$this->getAlias() . '.used' => 1, $this->getAlias() . '.created >=' => date(FORMAT_DB_DATETIME, time() - $this->validity)])->count();
 
-		$keys['unused_invalid'] = $this->find('count', ['conditions' => [$this->getAlias() . '.used' => 0, $this->getAlias() . '.created <' => date(FORMAT_DB_DATETIME, time() - $this->validity)]]);
-		$keys['used_invalid'] = $this->find('count', ['conditions' => [$this->getAlias() . '.used' => 1, $this->getAlias() . '.created <' => date(FORMAT_DB_DATETIME, time() - $this->validity)]]);
+		$keys['unused_invalid'] = $this->find()->where([$this->getAlias() . '.used' => 0, $this->getAlias() . '.created <' => date(FORMAT_DB_DATETIME, time() - $this->validity)])->count();
+		$keys['used_invalid'] = $this->find()->where([$this->getAlias() . '.used' => 1, $this->getAlias() . '.created <' => date(FORMAT_DB_DATETIME, time() - $this->validity)])->count();
 
 		$types = $this->find('all', ['conditions' => [], 'fields' => ['DISTINCT type']])->toArray();
 		$keys['types'] = !empty($types) ? Hash::extract($types, '{n}.type') : [];

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

@@ -48,7 +48,7 @@ class ControllerTest extends TestCase {
 
 		$ToolsUser = TableRegistry::getTableLocator()->get('ToolsUsers');
 
-		$count = $ToolsUser->find('count');
+		$count = $ToolsUser->find()->count();
 		$this->assertTrue($count > 3);
 
 		$this->Controller->loadModel('ToolsUsers');

+ 9 - 6
tests/TestCase/Model/Behavior/BitmaskedBehaviorTest.php

@@ -4,6 +4,7 @@ namespace Tools\Test\TestCase\Model\Behavior;
 
 use App\Model\Entity\BitmaskedComment;
 use Cake\ORM\TableRegistry;
+use RuntimeException;
 use Tools\TestSuite\TestCase;
 
 class BitmaskedBehaviorTest extends TestCase {
@@ -43,11 +44,13 @@ class BitmaskedBehaviorTest extends TestCase {
 
 	/**
 	 * @return void
-	 * @expectedException \RuntimeException
-	 * @expectedExceptionMessage Bits not found for field my_field, expected pluralized static method myFields() on the entity.
 	 */
 	public function testFieldMethodMissing() {
 		$this->Comments->removeBehavior('Bitmasked');
+
+		$this->expectException(RuntimeException::class);
+		$this->expectExceptionMessage('Bits not found for field my_field, expected pluralized static method myFields() on the entity.');
+
 		$this->Comments->addBehavior('Tools.Bitmasked', ['field' => 'my_field']);
 	}
 
@@ -144,7 +147,7 @@ class BitmaskedBehaviorTest extends TestCase {
 		$res = $this->Comments->save($entity);
 		$this->assertTrue((bool)$res);
 
-		$res = $this->Comments->find('first', ['conditions' => ['statuses' => $data['statuses']]]);
+		$res = $this->Comments->find()->where(['statuses IN' => $data['statuses']])->first();
 		$this->assertTrue(!empty($res));
 		$expected = BitmaskedComment::STATUS_APPROVED | BitmaskedComment::STATUS_PUBLISHED; // 6
 		$this->assertEquals($expected, $res['status']);
@@ -153,8 +156,8 @@ class BitmaskedBehaviorTest extends TestCase {
 		$this->assertEquals($expected, $res['statuses']);
 
 		// model.field syntax
-		$res = $this->Comments->find('first', ['conditions' => ['BitmaskedComments.statuses' => $data['statuses']]]);
-		$this->assertTrue((bool)$res->toArray());
+		$res = $this->Comments->find()->where(['BitmaskedComments.statuses IN' => $data['statuses']])->first();
+		$this->assertTrue((bool)$res);
 
 		// explicit
 		$activeApprovedAndPublished = BitmaskedComment::STATUS_ACTIVE | BitmaskedComment::STATUS_APPROVED | BitmaskedComment::STATUS_PUBLISHED;
@@ -166,7 +169,7 @@ class BitmaskedBehaviorTest extends TestCase {
 		$res = $this->Comments->save($entity);
 		$this->assertTrue((bool)$res);
 
-		$res = $this->Comments->find('first', ['conditions' => ['status' => $activeApprovedAndPublished]]);
+		$res = $this->Comments->find()->where(['status' => $activeApprovedAndPublished])->first();
 		$this->assertTrue((bool)$res);
 		$this->assertEquals($activeApprovedAndPublished, $res['status']);
 		$expected = [BitmaskedComment::STATUS_ACTIVE, BitmaskedComment::STATUS_PUBLISHED, BitmaskedComment::STATUS_APPROVED];

+ 3 - 3
tests/TestCase/Model/Behavior/ConfirmableBehaviorTest.php

@@ -35,7 +35,7 @@ class ConfirmableBehaviorTest extends TestCase {
 		$this->Articles = TableRegistry::getTableLocator()->get('SluggedArticles');
 		$this->Articles->addBehavior('Tools.Confirmable');
 
-		$animal = $this->Articles->newEntity();
+		$animal = $this->Articles->newEmptyEntity();
 
 		$data = [
 			'name' => 'FooBar',
@@ -73,7 +73,7 @@ class ConfirmableBehaviorTest extends TestCase {
 
 		$this->Articles->addBehavior('Tools.Confirmable');
 
-		$animal = $this->Articles->newEntity();
+		$animal = $this->Articles->newEmptyEntity();
 
 		$data = [
 			'name' => 'FooBar',
@@ -99,7 +99,7 @@ class ConfirmableBehaviorTest extends TestCase {
 		$this->Articles = TableRegistry::getTableLocator()->get('SluggedArticles');
 		$this->Articles->addBehavior('Tools.Confirmable');
 
-		$animal = $this->Articles->newEntity();
+		$animal = $this->Articles->newEmptyEntity();
 		$data = [
 			'name' => 'FooBar'
 		];

+ 24 - 24
tests/TestCase/Model/Behavior/PasswordableBehaviorTest.php

@@ -59,7 +59,7 @@ class PasswordableBehaviorTest extends TestCase {
 	public function testValidate() {
 		$this->Users->addBehavior('Tools.Passwordable', []);
 
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'pwd' => '123456',
 		];
@@ -68,7 +68,7 @@ class PasswordableBehaviorTest extends TestCase {
 		$this->assertFalse($is);
 		$this->assertEquals(['pwd_repeat'], array_keys((array)$user->getErrors()));
 
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'pwd' => '1234ab',
 			'pwd_repeat' => '123456'
@@ -78,7 +78,7 @@ class PasswordableBehaviorTest extends TestCase {
 		$this->assertFalse($is);
 		$this->assertEquals(['validateIdentical' => __d('tools', 'valErrPwdNotMatch')], $user->getErrors()['pwd_repeat']);
 
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'pwd' => '123456',
 			'pwd_repeat' => '123456'
@@ -95,7 +95,7 @@ class PasswordableBehaviorTest extends TestCase {
 	 */
 	public function testValidateNoConfirm() {
 		$this->Users->addBehavior('Tools.Passwordable', ['confirm' => false]);
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'pwd' => '123456',
 		];
@@ -112,7 +112,7 @@ class PasswordableBehaviorTest extends TestCase {
 	 */
 	public function testValidateRequired() {
 		$this->Users->addBehavior('Tools.Passwordable');
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'pwd' => '',
 			'pwd_repeat' => ''
@@ -130,7 +130,7 @@ class PasswordableBehaviorTest extends TestCase {
 	 */
 	public function testValidateNotRequired() {
 		$this->Users->addBehavior('Tools.Passwordable', ['require' => false]);
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'name' => 'foo', // we need at least one field besides the password on CREATE
 			'pwd' => '',
@@ -147,7 +147,7 @@ class PasswordableBehaviorTest extends TestCase {
 		$this->assertEquals($fields, $is->visibleProperties());
 
 		$id = $user->id;
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'id' => $id,
 			'pwd' => '',
@@ -171,7 +171,7 @@ class PasswordableBehaviorTest extends TestCase {
 	 */
 	public function testValidateEmptyWithCurrentPassword() {
 		$this->Users->addBehavior('Tools.Passwordable', ['current' => true]);
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'id' => '123',
 			'pwd' => '',
@@ -187,7 +187,7 @@ class PasswordableBehaviorTest extends TestCase {
 		$this->setUp();
 
 		$this->Users->addBehavior('Tools.Passwordable', ['require' => false, 'current' => true]);
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'name' => 'foo',
 			'pwd' => '',
@@ -210,7 +210,7 @@ class PasswordableBehaviorTest extends TestCase {
 			'formFieldRepeat' => 'passw_repeat',
 			'formFieldCurrent' => 'passw_current',
 		]);
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'passw' => '123456',
 			'passw_repeat' => '123456'
@@ -227,7 +227,7 @@ class PasswordableBehaviorTest extends TestCase {
 	 * @return void
 	 */
 	public function testNotSame() {
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'name' => 'admin',
 			'password' => $this->hasher->hash('somepwd'),
@@ -279,7 +279,7 @@ class PasswordableBehaviorTest extends TestCase {
 			'allowSame' => false,
 			'current' => false
 		]);
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'passw' => 'somepwd',
 			'passw_repeat' => 'somepwd'
@@ -320,7 +320,7 @@ class PasswordableBehaviorTest extends TestCase {
 			'formFieldRepeat' => 'passw_repeat',
 			'require' => false
 		]);
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'passw' => 'somepwd',
 			'passw_repeat' => 'somepwd'
@@ -366,7 +366,7 @@ class PasswordableBehaviorTest extends TestCase {
 	 */
 	public function testValidateCurrent() {
 		$this->assertFalse($this->Users->behaviors()->has('Passwordable'));
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'name' => 'xyz',
 			'password' => $this->hasher->hash('somepwd')];
@@ -451,7 +451,7 @@ class PasswordableBehaviorTest extends TestCase {
 	 */
 	public function testValidateCurrentOptional() {
 		$this->assertFalse($this->Users->behaviors()->has('Passwordable'));
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'name' => 'xyz',
 			'password' => $this->hasher->hash('somepwd')];
@@ -513,7 +513,7 @@ class PasswordableBehaviorTest extends TestCase {
 			'current' => false,
 			'passwordHasher' => 'Complex',
 		]);
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'pwd' => 'somepwd',
 			'pwd_repeat' => 'somepwd'
@@ -536,7 +536,7 @@ class PasswordableBehaviorTest extends TestCase {
 			'passwordHasher' => 'Complex',
 			'forceFieldList' => true
 		]);
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'name' => 'x',
 			'pwd' => 'somepwd',
@@ -566,7 +566,7 @@ class PasswordableBehaviorTest extends TestCase {
 			'authType' => 'Blowfish',
 		]);
 
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'pwd' => 'somepwd',
 			'pwd_repeat' => 'somepwd'
@@ -677,7 +677,7 @@ class PasswordableBehaviorTest extends TestCase {
 			'minLength' => 3,
 			'maxLength' => 6,
 		]);
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'pwd' => '123',
 			'pwd_repeat' => '123'
@@ -686,7 +686,7 @@ class PasswordableBehaviorTest extends TestCase {
 		$result = $this->Users->save($user);
 		$this->assertTrue((bool)$result);
 
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'pwd' => '12345678',
 			'pwd_repeat' => '12345678'
@@ -707,7 +707,7 @@ class PasswordableBehaviorTest extends TestCase {
 	 */
 	public function testSaveWithValidateFalse() {
 		$this->Users->addBehavior('Tools.Passwordable');
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'pwd' => '123',
 		];
@@ -749,7 +749,7 @@ class PasswordableBehaviorTest extends TestCase {
 		$this->Users->addBehavior('Tools.Passwordable', [
 			'customValidation' => $rules]);
 
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'pwd' => '%123456',
 			'pwd_repeat' => '%123456'
@@ -763,7 +763,7 @@ class PasswordableBehaviorTest extends TestCase {
 		$expected = ['pwd' => ['validateCustom' => 'Foo Bar']];
 		$this->assertSame($expected, $result);
 
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'pwd' => 'abc123',
 			'pwd_repeat' => 'abc123'
@@ -776,7 +776,7 @@ class PasswordableBehaviorTest extends TestCase {
 		$expected = ['pwd' => ['validateCustomExt' => 'Foo Bar Ext']];
 		$this->assertSame($expected, $result);
 
-		$user = $this->Users->newEntity();
+		$user = $this->Users->newEmptyEntity();
 		$data = [
 			'pwd' => 'abcdef',
 			'pwd_repeat' => 'abcdef'

+ 8 - 8
tests/TestCase/Model/Behavior/ResetBehaviorTest.php

@@ -123,13 +123,13 @@ class ResetBehaviorTest extends TestCase {
 		$this->Table->removeBehavior('Reset');
 		$this->Table->addBehavior('Tools.Reset', ['callback' => [$this->Table, 'customObjectCallback']]);
 
-		$x = $this->Table->find('first', ['conditions' => ['id' => 6]]);
+		$x = $this->Table->find()->where(['id' => 6])->first();
 		$this->assertEquals('Second Comment for Second Article', $x['comment']);
 
 		$result = $this->Table->resetRecords();
 		$this->assertTrue((bool)$result);
 
-		$x = $this->Table->find('first', ['conditions' => ['id' => 6]]);
+		$x = $this->Table->find()->where(['id' => 6])->first();
 		$expected = 'Second Comment for Second Article xxx';
 		$this->assertEquals($expected, $x['comment']);
 	}
@@ -143,13 +143,13 @@ class ResetBehaviorTest extends TestCase {
 		$this->Table->removeBehavior('Reset');
 		$this->Table->addBehavior('Tools.Reset', ['callback' => 'App\Model\Table\ResetCommentsTable::customStaticCallback']);
 
-		$x = $this->Table->find('first', ['conditions' => ['id' => 6]]);
+		$x = $this->Table->find()->where(['id' => 6])->first();
 		$this->assertEquals('Second Comment for Second Article', $x['comment']);
 
 		$result = $this->Table->resetRecords();
 		$this->assertTrue((bool)$result);
 
-		$x = $this->Table->find('first', ['conditions' => ['id' => 6]]);
+		$x = $this->Table->find()->where(['id' => 6])->first();
 		$expected = 'Second Comment for Second Article yyy';
 		$this->assertEquals($expected, $x['comment']);
 	}
@@ -166,13 +166,13 @@ class ResetBehaviorTest extends TestCase {
 			'updateFields' => ['comment'],
 			'callback' => 'App\Model\Table\ResetCommentsTable::fieldsCallback']);
 
-		$x = $this->Table->find('first', ['conditions' => ['id' => 6]]);
+		$x = $this->Table->find()->where(['id' => 6])->first();
 		$this->assertEquals('Second Comment for Second Article', $x['comment']);
 
 		$result = $this->Table->resetRecords();
 		$this->assertTrue((bool)$result);
 
-		$x = $this->Table->find('first', ['conditions' => ['id' => 6]]);
+		$x = $this->Table->find()->where(['id' => 6])->first();
 		$expected = 'foo';
 		$this->assertEquals($expected, $x['comment']);
 	}
@@ -189,13 +189,13 @@ class ResetBehaviorTest extends TestCase {
 			'updateFields' => ['id'],
 			'callback' => 'App\Model\Table\ResetCommentsTable::fieldsCallbackAuto']);
 
-		$x = $this->Table->find('first', ['conditions' => ['id' => 6]]);
+		$x = $this->Table->find()->where(['id' => 6])->first();
 		$this->assertEquals('Second Comment for Second Article', $x['comment']);
 
 		$result = $this->Table->resetRecords();
 		$this->assertTrue((bool)$result);
 
-		$x = $this->Table->find('first', ['conditions' => ['id' => 6]]);
+		$x = $this->Table->find()->where(['id' => 6])->first();
 		$expected = 'bar';
 		$this->assertEquals($expected, $x['comment']);
 	}

+ 1 - 1
tests/TestCase/Model/Behavior/TypeMapBehaviorTest.php

@@ -40,7 +40,7 @@ class TypeMapBehaviorTest extends TestCase {
 		$this->Table = TableRegistry::getTableLocator()->get('Data');
 		$this->Table->addBehavior('Tools.Jsonable', ['fields' => ['data_array']]);
 
-		$entity = $this->Table->newEntity();
+		$entity = $this->Table->newEmptyEntity();
 
 		$data = [
 			'name' => 'FooBar',

+ 3 - 37
tests/TestCase/Model/Table/TableTest.php

@@ -48,12 +48,10 @@ class TableTest extends TestCase {
 	}
 
 	/**
-	 * Test truncate
-	 *
 	 * @return void
 	 */
 	public function testTruncate() {
-		$is = $this->Users->find('count');
+		$is = $this->Users->find()->count();
 		$this->assertEquals(4, $is);
 
 		$config = ConnectionManager::getConfig('test');
@@ -62,8 +60,8 @@ class TableTest extends TestCase {
 			$this->assertEquals(5, $is);
 		}
 
-		$is = $this->Users->truncate();
-		$is = $this->Users->find('count');
+		$this->Users->truncate();
+		$is = $this->Users->find()->count();
 		$this->assertEquals(0, $is);
 
 		if ((strpos($config['driver'], 'Mysql') !== false)) {
@@ -73,8 +71,6 @@ class TableTest extends TestCase {
 	}
 
 	/**
-	 * TableTest::testTimestamp()
-	 *
 	 * @return void
 	 */
 	public function testTimestamp() {
@@ -86,34 +82,6 @@ class TableTest extends TestCase {
 	}
 
 	/**
-	 * Check shims
-	 *
-	 * @return void
-	 */
-	public function testFindFirst() {
-		$result = $this->Users->find('first', ['conditions' => ['name LIKE' => 'User %']]);
-		$this->assertEquals('User 1', $result['name']);
-
-		$result = $this->Users->find('first', ['conditions' => ['name NOT LIKE' => 'User %']]);
-		$this->assertNotEquals('User 1', $result['name']);
-	}
-
-	/**
-	 * Check shims
-	 *
-	 * @return void
-	 */
-	public function testFindCount() {
-		$result = $this->Users->find('count');
-		$this->assertEquals(4, $result);
-
-		$result = $this->Users->find('count', ['conditions' => ['name' => 'User 1']]);
-		$this->assertEquals(1, $result);
-	}
-
-	/**
-	 * TableTest::testField()
-	 *
 	 * @return void
 	 */
 	public function testField() {
@@ -125,8 +93,6 @@ class TableTest extends TestCase {
 	}
 
 	/**
-	 * TableTest::testField()
-	 *
 	 * @return void
 	 */
 	public function testFieldByConditions() {

+ 2 - 2
tests/TestCase/Model/Table/TokensTableTest.php

@@ -77,9 +77,9 @@ class TokensTableTest extends TestCase {
 		];
 		$entity = $this->Tokens->newEntity($data, ['validate' => false]);
 		$this->Tokens->save($entity);
-		$count = $this->Tokens->find('count');
+		$count = $this->Tokens->find()->count();
 		$this->Tokens->garbageCollector();
-		$count2 = $this->Tokens->find('count');
+		$count2 = $this->Tokens->find()->count();
 		$this->assertTrue($count > $count2);
 	}
 

+ 4 - 1
tests/bootstrap.php

@@ -74,8 +74,11 @@ $cache = [
 
 Cake\Cache\Cache::setConfig($cache);
 
+// Why is this required?
+require ROOT . DS . 'config' . DS . 'bootstrap.php';
+
 //Cake\Core\Plugin::load('Tools', ['path' => ROOT . DS, 'bootstrap' => true]);
-(new Cake\Core\PluginCollection)->add(new Tools\Plugin(['bootstrap' => true]));
+(new Cake\Core\PluginCollection)->add(new Tools\Plugin());
 
 if (getenv('db_dsn')) {
 	ConnectionManager::setConfig('test', [

+ 0 - 1
tests/phpstan.neon

@@ -1,7 +1,6 @@
 parameters:
     autoload_files:
     - %rootDir%/../../../tests/bootstrap.php
-    - %rootDir%/../../../config/bootstrap.php
     excludes_analyse:
         - %rootDir%/../../../src/TestSuite/*
         - %rootDir%/../../../src/View/Helper/TreeHelper

+ 1 - 1
tests/test_app/Model/Table/DataTable.php

@@ -12,7 +12,7 @@ class DataTable extends Table {
 	 *
 	 * @return \Cake\Database\Schema\TableSchema
 	 */
-	protected function _initializeSchema(TableSchema $schema) {
+	protected function _initializeSchema(TableSchema $schema): TableSchema {
 		$schema->setColumnType('data_json', 'json');
 		$schema->setColumnType('data_array', 'array');
 

+ 6 - 6
tests/test_app/Model/Table/ResetCommentsTable.php

@@ -11,7 +11,7 @@ class ResetCommentsTable extends Table {
 	 * @param array $config
 	 * @return void
 	 */
-	public function initialize(array $config) {
+	public function initialize(array $config): void {
 		$this->setDisplayField('comment');
 		parent::initialize($config);
 	}
@@ -21,7 +21,7 @@ class ResetCommentsTable extends Table {
 	 * @param array $updateFields
 	 * @return \Cake\ORM\Entity
 	 */
-	public function customCallback(Entity $record, &$updateFields) {
+	public function customCallback(Entity $record, array &$updateFields) {
 		$record->comment .= ' xyz';
 		$fields[] = 'some_other_field';
 		return $record;
@@ -32,7 +32,7 @@ class ResetCommentsTable extends Table {
 	 * @param array $updateFields
 	 * @return \Cake\ORM\Entity
 	 */
-	public function customObjectCallback(Entity $record, &$updateFields) {
+	public function customObjectCallback(Entity $record, array &$updateFields) {
 		$record['comment'] .= ' xxx';
 		$updateFields[] = 'some_other_field';
 		return $record;
@@ -43,7 +43,7 @@ class ResetCommentsTable extends Table {
 	 * @param array $updateFields
 	 * @return \Cake\ORM\Entity
 	 */
-	public static function customStaticCallback(Entity $record, &$updateFields) {
+	public static function customStaticCallback(Entity $record, array &$updateFields) {
 		$record['comment'] .= ' yyy';
 		$updateFields[] = 'some_other_field';
 		return $record;
@@ -54,7 +54,7 @@ class ResetCommentsTable extends Table {
 	 * @param array $updateFields
 	 * @return \Cake\ORM\Entity
 	 */
-	public static function fieldsCallback(Entity $record, &$updateFields) {
+	public static function fieldsCallback(Entity $record, array &$updateFields) {
 		$record['comment'] = 'foo';
 		return $record;
 	}
@@ -64,7 +64,7 @@ class ResetCommentsTable extends Table {
 	 * @param array $updateFields
 	 * @return \Cake\ORM\Entity
 	 */
-	public static function fieldsCallbackAuto(Entity $record, &$updateFields) {
+	public static function fieldsCallbackAuto(Entity $record, array &$updateFields) {
 		$record['comment'] = 'bar';
 		$updateFields[] = 'comment';
 		return $record;