|
|
@@ -335,9 +335,10 @@ class TableTest extends TestCase
|
|
|
public function testSchemaInitialize()
|
|
|
{
|
|
|
$schema = $this->connection->schemaCollection()->describe('users');
|
|
|
- $table = $this->getMock('Cake\ORM\Table', ['_initializeSchema'], [
|
|
|
- ['table' => 'users', 'connection' => $this->connection]
|
|
|
- ]);
|
|
|
+ $table = $this->getMockBuilder('Cake\ORM\Table')
|
|
|
+ ->setMethods(['_initializeSchema'])
|
|
|
+ ->setConstructorArgs([['table' => 'users', 'connection' => $this->connection]])
|
|
|
+ ->getMock();
|
|
|
$table->expects($this->once())
|
|
|
->method('_initializeSchema')
|
|
|
->with($schema)
|
|
|
@@ -874,12 +875,14 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testUpdateAllFailure()
|
|
|
{
|
|
|
- $table = $this->getMock(
|
|
|
- 'Cake\ORM\Table',
|
|
|
- ['query'],
|
|
|
- [['table' => 'users', 'connection' => $this->connection]]
|
|
|
- );
|
|
|
- $query = $this->getMock('Cake\ORM\Query', ['execute'], [$this->connection, $table]);
|
|
|
+ $table = $this->getMockBuilder('Cake\ORM\Table')
|
|
|
+ ->setMethods(['query'])
|
|
|
+ ->setConstructorArgs([['table' => 'users', 'connection' => $this->connection]])
|
|
|
+ ->getMock();
|
|
|
+ $query = $this->getMockBuilder('Cake\ORM\Query')
|
|
|
+ ->setMethods(['execute'])
|
|
|
+ ->setConstructorArgs([$this->connection, $table])
|
|
|
+ ->getMock();
|
|
|
$table->expects($this->once())
|
|
|
->method('query')
|
|
|
->will($this->returnValue($query));
|
|
|
@@ -937,12 +940,14 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testDeleteAllFailure()
|
|
|
{
|
|
|
- $table = $this->getMock(
|
|
|
- 'Cake\ORM\Table',
|
|
|
- ['query'],
|
|
|
- [['table' => 'users', 'connection' => $this->connection]]
|
|
|
- );
|
|
|
- $query = $this->getMock('Cake\ORM\Query', ['execute'], [$this->connection, $table]);
|
|
|
+ $table = $this->getMockBuilder('Cake\ORM\Table')
|
|
|
+ ->setMethods(['query'])
|
|
|
+ ->setConstructorArgs([['table' => 'users', 'connection' => $this->connection]])
|
|
|
+ ->getMock();
|
|
|
+ $query = $this->getMockBuilder('Cake\ORM\Query')
|
|
|
+ ->setMethods(['execute'])
|
|
|
+ ->setConstructorArgs([$this->connection, $table])
|
|
|
+ ->getMock();
|
|
|
$table->expects($this->once())
|
|
|
->method('query')
|
|
|
->will($this->returnValue($query));
|
|
|
@@ -961,12 +966,13 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testFindApplyOptions()
|
|
|
{
|
|
|
- $table = $this->getMock(
|
|
|
- 'Cake\ORM\Table',
|
|
|
- ['query', 'findAll'],
|
|
|
- [['table' => 'users', 'connection' => $this->connection]]
|
|
|
- );
|
|
|
- $query = $this->getMock('Cake\ORM\Query', [], [$this->connection, $table]);
|
|
|
+ $table = $this->getMockBuilder('Cake\ORM\Table')
|
|
|
+ ->setMethods(['query', 'findAll'])
|
|
|
+ ->setConstructorArgs([['table' => 'users', 'connection' => $this->connection]])
|
|
|
+ ->getMock();
|
|
|
+ $query = $this->getMockBuilder('Cake\ORM\Query')
|
|
|
+ ->setConstructorArgs([$this->connection, $table])
|
|
|
+ ->getMock();
|
|
|
$table->expects($this->once())
|
|
|
->method('query')
|
|
|
->will($this->returnValue($query));
|
|
|
@@ -1118,9 +1124,15 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testStackingFinders()
|
|
|
{
|
|
|
- $table = $this->getMock('\Cake\ORM\Table', ['find', 'findList'], [], '', false);
|
|
|
+ $table = $this->getMockBuilder('\Cake\ORM\Table')
|
|
|
+ ->setMethods(['find', 'findList'])
|
|
|
+ ->disableOriginalConstructor()
|
|
|
+ ->getMock();
|
|
|
$params = [$this->connection, $table];
|
|
|
- $query = $this->getMock('\Cake\ORM\Query', ['addDefaultTypes'], $params);
|
|
|
+ $query = $this->getMockBuilder('\Cake\ORM\Query')
|
|
|
+ ->setMethods(['addDefaultTypes'])
|
|
|
+ ->setConstructorArgs($params)
|
|
|
+ ->getMock();
|
|
|
|
|
|
$table->expects($this->once())
|
|
|
->method('find')
|
|
|
@@ -1522,7 +1534,9 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testAddBehavior()
|
|
|
{
|
|
|
- $mock = $this->getMock('Cake\ORM\BehaviorRegistry', [], [], '', false);
|
|
|
+ $mock = $this->getMockBuilder('Cake\ORM\BehaviorRegistry')
|
|
|
+ ->disableOriginalConstructor()
|
|
|
+ ->getMock();
|
|
|
$mock->expects($this->once())
|
|
|
->method('load')
|
|
|
->with('Sluggable');
|
|
|
@@ -1559,7 +1573,9 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testRemoveBehavior()
|
|
|
{
|
|
|
- $mock = $this->getMock('Cake\ORM\BehaviorRegistry', [], [], '', false);
|
|
|
+ $mock = $this->getMockBuilder('Cake\ORM\BehaviorRegistry')
|
|
|
+ ->disableOriginalConstructor()
|
|
|
+ ->getMock();
|
|
|
$mock->expects($this->once())
|
|
|
->method('unload')
|
|
|
->with('Sluggable');
|
|
|
@@ -1655,10 +1671,9 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testImplementedEvents()
|
|
|
{
|
|
|
- $table = $this->getMock(
|
|
|
- 'Cake\ORM\Table',
|
|
|
- ['beforeFind', 'beforeSave', 'afterSave', 'beforeDelete', 'afterDelete']
|
|
|
- );
|
|
|
+ $table = $this->getMockBuilder('Cake\ORM\Table')
|
|
|
+ ->setMethods(['beforeFind', 'beforeSave', 'afterSave', 'beforeDelete', 'afterDelete'])
|
|
|
+ ->getMock();
|
|
|
$result = $table->implementedEvents();
|
|
|
$expected = [
|
|
|
'Model.beforeFind' => 'beforeFind',
|
|
|
@@ -1713,15 +1728,14 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testSaveNewEntityNoExists()
|
|
|
{
|
|
|
- $table = $this->getMock(
|
|
|
- 'Cake\ORM\Table',
|
|
|
- ['exists'],
|
|
|
- [[
|
|
|
+ $table = $this->getMockBuilder('Cake\ORM\Table')
|
|
|
+ ->setMethods(['exists'])
|
|
|
+ ->setConstructorArgs([[
|
|
|
'connection' => $this->connection,
|
|
|
'alias' => 'Users',
|
|
|
'table' => 'users',
|
|
|
- ]]
|
|
|
- );
|
|
|
+ ]])
|
|
|
+ ->getMock();
|
|
|
$entity = $table->newEntity(['username' => 'mark']);
|
|
|
$this->assertTrue($entity->isNew());
|
|
|
|
|
|
@@ -1739,17 +1753,14 @@ class TableTest extends TestCase
|
|
|
public function testSavePrimaryKeyEntityExists()
|
|
|
{
|
|
|
$this->skipIfSqlServer();
|
|
|
- $table = $this->getMock(
|
|
|
- 'Cake\ORM\Table',
|
|
|
- ['exists'],
|
|
|
- [
|
|
|
- [
|
|
|
- 'connection' => $this->connection,
|
|
|
- 'alias' => 'Users',
|
|
|
- 'table' => 'users',
|
|
|
- ]
|
|
|
- ]
|
|
|
- );
|
|
|
+ $table = $this->getMockBuilder('Cake\ORM\Table')
|
|
|
+ ->setMethods(['exists'])
|
|
|
+ ->setConstructorArgs([[
|
|
|
+ 'connection' => $this->connection,
|
|
|
+ 'alias' => 'Users',
|
|
|
+ 'table' => 'users',
|
|
|
+ ]])
|
|
|
+ ->getMock();
|
|
|
$entity = $table->newEntity(['id' => 20, 'username' => 'mark']);
|
|
|
$this->assertTrue($entity->isNew());
|
|
|
|
|
|
@@ -2052,17 +2063,14 @@ class TableTest extends TestCase
|
|
|
public function testSavePrimaryKeyEntityNoExists()
|
|
|
{
|
|
|
$this->skipIfSqlServer();
|
|
|
- $table = $this->getMock(
|
|
|
- 'Cake\ORM\Table',
|
|
|
- ['exists'],
|
|
|
- [
|
|
|
- [
|
|
|
- 'connection' => $this->connection,
|
|
|
- 'alias' => 'Users',
|
|
|
- 'table' => 'users',
|
|
|
- ]
|
|
|
- ]
|
|
|
- );
|
|
|
+ $table = $this->getMockBuilder('Cake\ORM\Table')
|
|
|
+ ->setMethods(['exists'])
|
|
|
+ ->setConstructorArgs([[
|
|
|
+ 'connection' => $this->connection,
|
|
|
+ 'alias' => 'Users',
|
|
|
+ 'table' => 'users',
|
|
|
+ ]])
|
|
|
+ ->getMock();
|
|
|
$entity = $table->newEntity(['id' => 20, 'username' => 'mark']);
|
|
|
$this->assertTrue($entity->isNew());
|
|
|
|
|
|
@@ -2306,16 +2314,14 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testAfterSaveNotCalled()
|
|
|
{
|
|
|
- $table = $this->getMock(
|
|
|
- '\Cake\ORM\Table',
|
|
|
- ['query'],
|
|
|
- [['table' => 'users', 'connection' => $this->connection]]
|
|
|
- );
|
|
|
- $query = $this->getMock(
|
|
|
- '\Cake\ORM\Query',
|
|
|
- ['execute', 'addDefaultTypes'],
|
|
|
- [null, $table]
|
|
|
- );
|
|
|
+ $table = $this->getMockBuilder('\Cake\ORM\Table')
|
|
|
+ ->setMethods(['query'])
|
|
|
+ ->setConstructorArgs([['table' => 'users', 'connection' => $this->connection]])
|
|
|
+ ->getMock();
|
|
|
+ $query = $this->getMockBuilder('\Cake\ORM\Query')
|
|
|
+ ->setMethods(['execute', 'addDefaultTypes'])
|
|
|
+ ->setConstructorArgs([null, $table])
|
|
|
+ ->getMock();
|
|
|
$statement = $this->getMockBuilder('\Cake\Database\Statement\StatementDecorator')->getMock();
|
|
|
$data = new \Cake\ORM\Entity([
|
|
|
'username' => 'superuser',
|
|
|
@@ -2417,14 +2423,16 @@ class TableTest extends TestCase
|
|
|
{
|
|
|
$config = ConnectionManager::config('test');
|
|
|
|
|
|
- $connection = $this->getMock(
|
|
|
- '\Cake\Database\Connection',
|
|
|
- ['begin', 'commit'],
|
|
|
- [$config]
|
|
|
- );
|
|
|
+ $connection = $this->getMockBuilder('\Cake\Database\Connection')
|
|
|
+ ->setMethods(['begin', 'commit'])
|
|
|
+ ->setConstructorArgs([$config])
|
|
|
+ ->getMock();
|
|
|
$connection->driver($this->connection->driver());
|
|
|
|
|
|
- $table = $this->getMock('\Cake\ORM\Table', ['connection'], [['table' => 'users']]);
|
|
|
+ $table = $this->getMockBuilder('\Cake\ORM\Table')
|
|
|
+ ->setMethods(['connection'])
|
|
|
+ ->setConstructorArgs([['table' => 'users']])
|
|
|
+ ->getMock();
|
|
|
$table->expects($this->any())->method('connection')
|
|
|
->will($this->returnValue($connection));
|
|
|
|
|
|
@@ -2447,22 +2455,19 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testAtomicSaveRollback()
|
|
|
{
|
|
|
- $connection = $this->getMock(
|
|
|
- '\Cake\Database\Connection',
|
|
|
- ['begin', 'rollback'],
|
|
|
- [ConnectionManager::config('test')]
|
|
|
- );
|
|
|
+ $connection = $this->getMockBuilder('\Cake\Database\Connection')
|
|
|
+ ->setMethods(['begin', 'rollback'])
|
|
|
+ ->setConstructorArgs([ConnectionManager::config('test')])
|
|
|
+ ->getMock();
|
|
|
$connection->driver(ConnectionManager::get('test')->driver());
|
|
|
- $table = $this->getMock(
|
|
|
- '\Cake\ORM\Table',
|
|
|
- ['query', 'connection'],
|
|
|
- [['table' => 'users']]
|
|
|
- );
|
|
|
- $query = $this->getMock(
|
|
|
- '\Cake\ORM\Query',
|
|
|
- ['execute', 'addDefaultTypes'],
|
|
|
- [null, $table]
|
|
|
- );
|
|
|
+ $table = $this->getMockBuilder('\Cake\ORM\Table')
|
|
|
+ ->setMethods(['query', 'connection'])
|
|
|
+ ->setConstructorArgs([['table' => 'users']])
|
|
|
+ ->getMock();
|
|
|
+ $query = $this->getMockBuilder('\Cake\ORM\Query')
|
|
|
+ ->setMethods(['execute', 'addDefaultTypes'])
|
|
|
+ ->setConstructorArgs([null, $table])
|
|
|
+ ->getMock();
|
|
|
$table->expects($this->any())->method('connection')
|
|
|
->will($this->returnValue($connection));
|
|
|
|
|
|
@@ -2490,22 +2495,19 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testAtomicSaveRollbackOnFailure()
|
|
|
{
|
|
|
- $connection = $this->getMock(
|
|
|
- '\Cake\Database\Connection',
|
|
|
- ['begin', 'rollback'],
|
|
|
- [ConnectionManager::config('test')]
|
|
|
- );
|
|
|
+ $connection = $this->getMockBuilder('\Cake\Database\Connection')
|
|
|
+ ->setMethods(['begin', 'rollback'])
|
|
|
+ ->setConstructorArgs([ConnectionManager::config('test')])
|
|
|
+ ->getMock();
|
|
|
$connection->driver(ConnectionManager::get('test')->driver());
|
|
|
- $table = $this->getMock(
|
|
|
- '\Cake\ORM\Table',
|
|
|
- ['query', 'connection', 'exists'],
|
|
|
- [['table' => 'users']]
|
|
|
- );
|
|
|
- $query = $this->getMock(
|
|
|
- '\Cake\ORM\Query',
|
|
|
- ['execute', 'addDefaultTypes'],
|
|
|
- [null, $table]
|
|
|
- );
|
|
|
+ $table = $this->getMockBuilder('\Cake\ORM\Table')
|
|
|
+ ->setMethods(['query', 'connection', 'exists'])
|
|
|
+ ->setConstructorArgs([['table' => 'users']])
|
|
|
+ ->getMock();
|
|
|
+ $query = $this->getMockBuilder('\Cake\ORM\Query')
|
|
|
+ ->setMethods(['execute', 'addDefaultTypes'])
|
|
|
+ ->setConstructorArgs([null, $table])
|
|
|
+ ->getMock();
|
|
|
|
|
|
$table->expects($this->any())->method('connection')
|
|
|
->will($this->returnValue($connection));
|
|
|
@@ -2659,11 +2661,10 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testSaveUpdateWithHint()
|
|
|
{
|
|
|
- $table = $this->getMock(
|
|
|
- '\Cake\ORM\Table',
|
|
|
- ['exists'],
|
|
|
- [['table' => 'users', 'connection' => ConnectionManager::get('test')]]
|
|
|
- );
|
|
|
+ $table = $this->getMockBuilder('\Cake\ORM\Table')
|
|
|
+ ->setMethods(['exists'])
|
|
|
+ ->setConstructorArgs([['table' => 'users', 'connection' => ConnectionManager::get('test')]])
|
|
|
+ ->getMock();
|
|
|
$entity = new \Cake\ORM\Entity([
|
|
|
'id' => 2,
|
|
|
'username' => 'baggins'
|
|
|
@@ -2682,17 +2683,15 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testSaveUpdatePrimaryKeyNotModified()
|
|
|
{
|
|
|
- $table = $this->getMock(
|
|
|
- '\Cake\ORM\Table',
|
|
|
- ['query'],
|
|
|
- [['table' => 'users', 'connection' => $this->connection]]
|
|
|
- );
|
|
|
+ $table = $this->getMockBuilder('\Cake\ORM\Table')
|
|
|
+ ->setMethods(['query'])
|
|
|
+ ->setConstructorArgs([['table' => 'users', 'connection' => $this->connection]])
|
|
|
+ ->getMock();
|
|
|
|
|
|
- $query = $this->getMock(
|
|
|
- '\Cake\ORM\Query',
|
|
|
- ['execute', 'addDefaultTypes', 'set'],
|
|
|
- [null, $table]
|
|
|
- );
|
|
|
+ $query = $this->getMockBuilder('\Cake\ORM\Query')
|
|
|
+ ->setMethods(['execute', 'addDefaultTypes', 'set'])
|
|
|
+ ->setConstructorArgs([null, $table])
|
|
|
+ ->getMock();
|
|
|
|
|
|
$table->expects($this->once())->method('query')
|
|
|
->will($this->returnValue($query));
|
|
|
@@ -2726,11 +2725,10 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testUpdateNoChange()
|
|
|
{
|
|
|
- $table = $this->getMock(
|
|
|
- '\Cake\ORM\Table',
|
|
|
- ['query'],
|
|
|
- [['table' => 'users', 'connection' => $this->connection]]
|
|
|
- );
|
|
|
+ $table = $this->getMockBuilder('\Cake\ORM\Table')
|
|
|
+ ->setMethods(['query'])
|
|
|
+ ->setConstructorArgs([['table' => 'users', 'connection' => $this->connection]])
|
|
|
+ ->getMock();
|
|
|
$table->expects($this->never())->method('query');
|
|
|
$entity = new \Cake\ORM\Entity([
|
|
|
'id' => 2,
|
|
|
@@ -2765,11 +2763,10 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testUpdateNoPrimaryButOtherKeys()
|
|
|
{
|
|
|
- $table = $this->getMock(
|
|
|
- '\Cake\ORM\Table',
|
|
|
- ['query'],
|
|
|
- [['table' => 'users', 'connection' => $this->connection]]
|
|
|
- );
|
|
|
+ $table = $this->getMockBuilder('\Cake\ORM\Table')
|
|
|
+ ->setMethods(['query'])
|
|
|
+ ->setConstructorArgs([['table' => 'users', 'connection' => $this->connection]])
|
|
|
+ ->getMock();
|
|
|
$table->expects($this->never())->method('query');
|
|
|
$entity = new \Cake\ORM\Entity([
|
|
|
'username' => 'mariano',
|
|
|
@@ -3182,11 +3179,10 @@ class TableTest extends TestCase
|
|
|
{
|
|
|
$entity = new \Cake\ORM\Entity(['id' => 1, 'name' => 'mark']);
|
|
|
|
|
|
- $table = $this->getMock(
|
|
|
- 'Cake\ORM\Table',
|
|
|
- ['query'],
|
|
|
- [['connection' => $this->connection]]
|
|
|
- );
|
|
|
+ $table = $this->getMockBuilder('Cake\ORM\Table')
|
|
|
+ ->setMethods(['query'])
|
|
|
+ ->setConstructorArgs([['connection' => $this->connection]])
|
|
|
+ ->getMock();
|
|
|
$table->expects($this->never())
|
|
|
->method('query');
|
|
|
|
|
|
@@ -3230,7 +3226,9 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function functionTestValidationWithDefiner()
|
|
|
{
|
|
|
- $table = $this->getMock('\Cake\ORM\Table', ['validationForOtherStuff']);
|
|
|
+ $table = $this->getMockBuilder('\Cake\ORM\Table')
|
|
|
+ ->setMethods(['validationForOtherStuff'])
|
|
|
+ ->getMock();
|
|
|
$table->expects($this->once())->method('validationForOtherStuff')
|
|
|
->will($this->returnArgument(0));
|
|
|
$other = $table->validator('forOtherStuff');
|
|
|
@@ -3803,7 +3801,9 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testSaveCleanEntity()
|
|
|
{
|
|
|
- $table = $this->getMock('\Cake\ORM\Table', ['_processSave']);
|
|
|
+ $table = $this->getMockBuilder('\Cake\ORM\Table')
|
|
|
+ ->setMethods(['_processSave'])
|
|
|
+ ->getMock();
|
|
|
$entity = new \Cake\ORM\Entity(
|
|
|
['id' => 'foo'],
|
|
|
['markNew' => false, 'markClean' => true]
|
|
|
@@ -3845,30 +3845,26 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testSaveDeepAssociationOptions()
|
|
|
{
|
|
|
- $articles = $this->getMock(
|
|
|
- '\Cake\ORM\Table',
|
|
|
- ['_insert'],
|
|
|
- [['table' => 'articles', 'connection' => $this->connection]]
|
|
|
- );
|
|
|
- $authors = $this->getMock(
|
|
|
- '\Cake\ORM\Table',
|
|
|
- ['_insert'],
|
|
|
- [['table' => 'authors', 'connection' => $this->connection]]
|
|
|
- );
|
|
|
- $supervisors = $this->getMock(
|
|
|
- '\Cake\ORM\Table',
|
|
|
- ['_insert', 'validate'],
|
|
|
- [[
|
|
|
+ $articles = $this->getMockBuilder('\Cake\ORM\Table')
|
|
|
+ ->setMethods(['_insert'])
|
|
|
+ ->setConstructorArgs([['table' => 'articles', 'connection' => $this->connection]])
|
|
|
+ ->getMock();
|
|
|
+ $authors = $this->getMockBuilder('\Cake\ORM\Table')
|
|
|
+ ->setMethods(['_insert'])
|
|
|
+ ->setConstructorArgs([['table' => 'authors', 'connection' => $this->connection]])
|
|
|
+ ->getMock();
|
|
|
+ $supervisors = $this->getMockBuilder('\Cake\ORM\Table')
|
|
|
+ ->setMethods(['_insert', 'validate'])
|
|
|
+ ->setConstructorArgs([[
|
|
|
'table' => 'authors',
|
|
|
'alias' => 'supervisors',
|
|
|
'connection' => $this->connection
|
|
|
- ]]
|
|
|
- );
|
|
|
- $tags = $this->getMock(
|
|
|
- '\Cake\ORM\Table',
|
|
|
- ['_insert'],
|
|
|
- [['table' => 'tags', 'connection' => $this->connection]]
|
|
|
- );
|
|
|
+ ]])
|
|
|
+ ->getMock();
|
|
|
+ $tags = $this->getMockBuilder('\Cake\ORM\Table')
|
|
|
+ ->setMethods(['_insert'])
|
|
|
+ ->setConstructorArgs([['table' => 'tags', 'connection' => $this->connection]])
|
|
|
+ ->getMock();
|
|
|
|
|
|
$articles->belongsTo('authors', ['targetTable' => $authors]);
|
|
|
$authors->hasOne('supervisors', ['targetTable' => $supervisors]);
|
|
|
@@ -4226,24 +4222,22 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testReplaceHasManyOnErrorDependentCascadeCallbacks()
|
|
|
{
|
|
|
- $articles = $this->getMock(
|
|
|
- 'Cake\ORM\Table',
|
|
|
- ['delete'],
|
|
|
- [[
|
|
|
+ $articles = $this->getMockBuilder('Cake\ORM\Table')
|
|
|
+ ->setMethods(['delete'])
|
|
|
+ ->setConstructorArgs([[
|
|
|
'connection' => $this->connection,
|
|
|
'alias' => 'Articles',
|
|
|
'table' => 'articles',
|
|
|
- ]]
|
|
|
- );
|
|
|
+ ]])
|
|
|
+ ->getMock();
|
|
|
|
|
|
$articles->method('delete')->willReturn(false);
|
|
|
|
|
|
$associations = new AssociationCollection();
|
|
|
|
|
|
- $hasManyArticles = $this->getMock(
|
|
|
- 'Cake\ORM\Association\HasMany',
|
|
|
- ['target'],
|
|
|
- [
|
|
|
+ $hasManyArticles = $this->getMockBuilder('Cake\ORM\Association\HasMany')
|
|
|
+ ->setMethods(['target'])
|
|
|
+ ->setConstructorArgs([
|
|
|
'articles',
|
|
|
[
|
|
|
'target' => $articles,
|
|
|
@@ -4251,8 +4245,8 @@ class TableTest extends TestCase
|
|
|
'dependent' => true,
|
|
|
'cascadeCallbacks' => true
|
|
|
]
|
|
|
- ]
|
|
|
- );
|
|
|
+ ])
|
|
|
+ ->getMock();
|
|
|
$hasManyArticles->method('target')->willReturn($articles);
|
|
|
|
|
|
$associations->add('articles', $hasManyArticles);
|
|
|
@@ -5021,14 +5015,13 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testSimplifiedFind()
|
|
|
{
|
|
|
- $table = $this->getMock(
|
|
|
- '\Cake\ORM\Table',
|
|
|
- ['callFinder'],
|
|
|
- [[
|
|
|
+ $table = $this->getMockBuilder('\Cake\ORM\Table')
|
|
|
+ ->setMethods(['callFinder'])
|
|
|
+ ->setConstructorArgs([[
|
|
|
'connection' => $this->connection,
|
|
|
'schema' => ['id' => ['type' => 'integer']]
|
|
|
- ]]
|
|
|
- );
|
|
|
+ ]])
|
|
|
+ ->getMock();
|
|
|
|
|
|
$query = (new \Cake\ORM\Query($this->connection, $table))->select();
|
|
|
$table->expects($this->once())->method('callFinder')
|
|
|
@@ -5054,24 +5047,22 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testGet($options)
|
|
|
{
|
|
|
- $table = $this->getMock(
|
|
|
- '\Cake\ORM\Table',
|
|
|
- ['callFinder', 'query'],
|
|
|
- [[
|
|
|
+ $table = $this->getMockBuilder('\Cake\ORM\Table')
|
|
|
+ ->setMethods(['callFinder', 'query'])
|
|
|
+ ->setConstructorArgs([[
|
|
|
'connection' => $this->connection,
|
|
|
'schema' => [
|
|
|
'id' => ['type' => 'integer'],
|
|
|
'bar' => ['type' => 'integer'],
|
|
|
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['bar']]]
|
|
|
]
|
|
|
- ]]
|
|
|
- );
|
|
|
+ ]])
|
|
|
+ ->getMock();
|
|
|
|
|
|
- $query = $this->getMock(
|
|
|
- '\Cake\ORM\Query',
|
|
|
- ['addDefaultTypes', 'firstOrFail', 'where', 'cache'],
|
|
|
- [$this->connection, $table]
|
|
|
- );
|
|
|
+ $query = $this->getMockBuilder('\Cake\ORM\Query')
|
|
|
+ ->setMethods(['addDefaultTypes', 'firstOrFail', 'where', 'cache'])
|
|
|
+ ->setConstructorArgs([$this->connection, $table])
|
|
|
+ ->getMock();
|
|
|
|
|
|
$entity = new \Cake\ORM\Entity;
|
|
|
$table->expects($this->once())->method('query')
|
|
|
@@ -5106,24 +5097,22 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testGetWithCustomFinder($options)
|
|
|
{
|
|
|
- $table = $this->getMock(
|
|
|
- '\Cake\ORM\Table',
|
|
|
- ['callFinder', 'query'],
|
|
|
- [[
|
|
|
+ $table = $this->getMockBuilder('\Cake\ORM\Table')
|
|
|
+ ->setMethods(['callFinder', 'query'])
|
|
|
+ ->setConstructorArgs([[
|
|
|
'connection' => $this->connection,
|
|
|
'schema' => [
|
|
|
'id' => ['type' => 'integer'],
|
|
|
'bar' => ['type' => 'integer'],
|
|
|
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['bar']]]
|
|
|
]
|
|
|
- ]]
|
|
|
- );
|
|
|
+ ]])
|
|
|
+ ->getMock();
|
|
|
|
|
|
- $query = $this->getMock(
|
|
|
- '\Cake\ORM\Query',
|
|
|
- ['addDefaultTypes', 'firstOrFail', 'where', 'cache'],
|
|
|
- [$this->connection, $table]
|
|
|
- );
|
|
|
+ $query = $this->getMockBuilder('\Cake\ORM\Query')
|
|
|
+ ->setMethods(['addDefaultTypes', 'firstOrFail', 'where', 'cache'])
|
|
|
+ ->setConstructorArgs([$this->connection, $table])
|
|
|
+ ->getMock();
|
|
|
|
|
|
$entity = new \Cake\ORM\Entity;
|
|
|
$table->expects($this->once())->method('query')
|
|
|
@@ -5167,25 +5156,23 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testGetWithCache($options, $cacheKey, $cacheConfig)
|
|
|
{
|
|
|
- $table = $this->getMock(
|
|
|
- '\Cake\ORM\Table',
|
|
|
- ['callFinder', 'query'],
|
|
|
- [[
|
|
|
+ $table = $this->getMockBuilder('\Cake\ORM\Table')
|
|
|
+ ->setMethods(['callFinder', 'query'])
|
|
|
+ ->setConstructorArgs([[
|
|
|
'connection' => $this->connection,
|
|
|
'schema' => [
|
|
|
'id' => ['type' => 'integer'],
|
|
|
'bar' => ['type' => 'integer'],
|
|
|
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['bar']]]
|
|
|
]
|
|
|
- ]]
|
|
|
- );
|
|
|
+ ]])
|
|
|
+ ->getMock();
|
|
|
$table->table('table_name');
|
|
|
|
|
|
- $query = $this->getMock(
|
|
|
- '\Cake\ORM\Query',
|
|
|
- ['addDefaultTypes', 'firstOrFail', 'where', 'cache'],
|
|
|
- [$this->connection, $table]
|
|
|
- );
|
|
|
+ $query = $this->getMockBuilder('\Cake\ORM\Query')
|
|
|
+ ->setMethods(['addDefaultTypes', 'firstOrFail', 'where', 'cache'])
|
|
|
+ ->setConstructorArgs([$this->connection, $table])
|
|
|
+ ->getMock();
|
|
|
|
|
|
$entity = new \Cake\ORM\Entity;
|
|
|
$table->expects($this->once())->method('query')
|
|
|
@@ -5265,8 +5252,12 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testPatchEntity()
|
|
|
{
|
|
|
- $table = $this->getMock('Cake\ORM\Table', ['marshaller']);
|
|
|
- $marshaller = $this->getMock('Cake\ORM\Marshaller', [], [$table]);
|
|
|
+ $table = $this->getMockBuilder('Cake\ORM\Table')
|
|
|
+ ->setMethods(['marshaller'])
|
|
|
+ ->getMock();
|
|
|
+ $marshaller = $this->getMockBuilder('Cake\ORM\Marshaller')
|
|
|
+ ->setConstructorArgs([$table])
|
|
|
+ ->getMock();
|
|
|
$table->belongsTo('users');
|
|
|
$table->hasMany('articles');
|
|
|
$table->expects($this->once())->method('marshaller')
|
|
|
@@ -5289,8 +5280,12 @@ class TableTest extends TestCase
|
|
|
*/
|
|
|
public function testPatchEntities()
|
|
|
{
|
|
|
- $table = $this->getMock('Cake\ORM\Table', ['marshaller']);
|
|
|
- $marshaller = $this->getMock('Cake\ORM\Marshaller', [], [$table]);
|
|
|
+ $table = $this->getMockBuilder('Cake\ORM\Table')
|
|
|
+ ->setMethods(['marshaller'])
|
|
|
+ ->getMock();
|
|
|
+ $marshaller = $this->getMockBuilder('Cake\ORM\Marshaller')
|
|
|
+ ->setConstructorArgs([$table])
|
|
|
+ ->getMock();
|
|
|
$table->belongsTo('users');
|
|
|
$table->hasMany('articles');
|
|
|
$table->expects($this->once())->method('marshaller')
|