Skip to content
Permalink
Browse files

remove getMock() deprecations

  • Loading branch information...
antograssiot committed Jun 7, 2016
1 parent 27dc37b commit 197d2d773439c9acc5f4717858c82c432d3c4bf5
@@ -42,23 +42,21 @@ class BelongsToManyTest extends TestCase
public function setUp()
{
parent::setUp();
$this->tag = $this->getMock(
'Cake\ORM\Table',
['find', 'delete'],
[['alias' => 'Tags', 'table' => 'tags']]
);
$this->tag = $this->getMockBuilder('Cake\ORM\Table')
->setMethods(['find', 'delete'])
->setConstructorArgs([['alias' => 'Tags', 'table' => 'tags']])
->getMock();
$this->tag->schema([
'id' => ['type' => 'integer'],
'name' => ['type' => 'string'],
'_constraints' => [
'primary' => ['type' => 'primary', 'columns' => ['id']]
]
]);
$this->article = $this->getMock(
'Cake\ORM\Table',
['find', 'delete'],
[['alias' => 'Articles', 'table' => 'articles']]
);
$this->article = $this->getMockBuilder('Cake\ORM\Table')
->setMethods(['find', 'delete'])
->setConstructorArgs([['alias' => 'Articles', 'table' => 'articles']])
->getMock();
$this->article->schema([
'id' => ['type' => 'integer'],
'name' => ['type' => 'string'],
@@ -258,7 +256,9 @@ public function testSaveStrategyInvalid()
*/
public function testCascadeDelete()
{
$articleTag = $this->getMock('Cake\ORM\Table', ['deleteAll'], []);
$articleTag = $this->getMockBuilder('Cake\ORM\Table')
->setMethods(['deleteAll'])
->getMock();
$config = [
'sourceTable' => $this->article,
'targetTable' => $this->tag,
@@ -288,7 +288,9 @@ public function testCascadeDelete()
*/
public function testCascadeDeleteDependent()
{
$articleTag = $this->getMock('Cake\ORM\Table', ['delete', 'deleteAll'], []);
$articleTag = $this->getMockBuilder('Cake\ORM\Table')
->setMethods(['delete', 'deleteAll'])
->getMock();
$config = [
'sourceTable' => $this->article,
'targetTable' => $this->tag,
@@ -327,7 +329,9 @@ public function testCascadeDeleteWithCallbacks()
$association->junction($articleTag);
$this->article->association($articleTag->alias());
$counter = $this->getMock('StdClass', ['__invoke']);
$counter = $this->getMockBuilder('StdClass')
->setMethods(['__invoke'])
->getMock();
$counter->expects($this->exactly(2))->method('__invoke');
$articleTag->eventManager()->on('Model.beforeDelete', $counter);
@@ -386,11 +390,11 @@ public function testLinkWithNotPersistedTarget()
public function testLinkSuccess()
{
$connection = ConnectionManager::get('test');
$joint = $this->getMock(
'\Cake\ORM\Table',
['save'],
[['alias' => 'ArticlesTags', 'connection' => $connection]]
);
$joint = $this->getMockBuilder('\Cake\ORM\Table')
->setMethods(['save'])
->setConstructorArgs([['alias' => 'ArticlesTags', 'connection' => $connection]])
->getMock();
$config = [
'sourceTable' => $this->article,
'targetTable' => $this->tag,
@@ -696,13 +700,14 @@ public function testSaveAssociatedNotEmptyNotIterable()
*/
public function testSaveAssociatedEmptySetSuccess($value)
{
$table = $this->getMock('Cake\ORM\Table', ['table'], [[]]);
$table = $this->getMockBuilder('Cake\ORM\Table')
->setMethods(['table'])
->getMock();
$table->schema([]);
$assoc = $this->getMock(
'\Cake\ORM\Association\BelongsToMany',
['_saveTarget', 'replaceLinks'],
['tags', ['sourceTable' => $table]]
);
$assoc = $this->getMockBuilder('\Cake\ORM\Association\BelongsToMany')
->setMethods(['_saveTarget', 'replaceLinks'])
->setConstructorArgs(['tags', ['sourceTable' => $table]])
->getMock();
$entity = new Entity([
'id' => 1,
'tags' => $value,
@@ -724,13 +729,14 @@ public function testSaveAssociatedEmptySetSuccess($value)
*/
public function testSaveAssociatedEmptySetUpdateSuccess($value)
{
$table = $this->getMock('Cake\ORM\Table', ['table'], [[]]);
$table = $this->getMockBuilder('Cake\ORM\Table')
->setMethods(['table'])
->getMock();
$table->schema([]);
$assoc = $this->getMock(
'\Cake\ORM\Association\BelongsToMany',
['_saveTarget', 'replaceLinks'],
['tags', ['sourceTable' => $table]]
);
$assoc = $this->getMockBuilder('\Cake\ORM\Association\BelongsToMany')
->setMethods(['_saveTarget', 'replaceLinks'])
->setConstructorArgs(['tags', ['sourceTable' => $table]])
->getMock();
$entity = new Entity([
'id' => 1,
'tags' => $value,
@@ -755,13 +761,14 @@ public function testSaveAssociatedEmptySetUpdateSuccess($value)
*/
public function testSaveAssociatedWithReplace()
{
$table = $this->getMock('Cake\ORM\Table', ['table'], [[]]);
$table = $this->getMockBuilder('Cake\ORM\Table')
->setMethods(['table'])
->getMock();
$table->schema([]);
$assoc = $this->getMock(
'\Cake\ORM\Association\BelongsToMany',
['replaceLinks'],
['tags', ['sourceTable' => $table]]
);
$assoc = $this->getMockBuilder('\Cake\ORM\Association\BelongsToMany')
->setMethods(['replaceLinks'])
->setConstructorArgs(['tags', ['sourceTable' => $table]])
->getMock();
$entity = new Entity([
'id' => 1,
'tags' => [
@@ -784,13 +791,14 @@ public function testSaveAssociatedWithReplace()
*/
public function testSaveAssociatedWithReplaceReturnFalse()
{
$table = $this->getMock('Cake\ORM\Table', ['table'], [[]]);
$table = $this->getMockBuilder('Cake\ORM\Table')
->setMethods(['table'])
->getMock();
$table->schema([]);
$assoc = $this->getMock(
'\Cake\ORM\Association\BelongsToMany',
['replaceLinks'],
['tags', ['sourceTable' => $table]]
);
$assoc = $this->getMockBuilder('\Cake\ORM\Association\BelongsToMany')
->setMethods(['replaceLinks'])
->setConstructorArgs(['tags', ['sourceTable' => $table]])
->getMock();
$entity = new Entity([
'id' => 1,
'tags' => [
@@ -814,11 +822,10 @@ public function testSaveAssociatedWithReplaceReturnFalse()
public function testSaveAssociatedOnlyEntitiesAppend()
{
$connection = ConnectionManager::get('test');
$mock = $this->getMock(
'Cake\ORM\Table',
['saveAssociated', 'schema'],
[['table' => 'tags', 'connection' => $connection]]
);
$mock = $this->getMockBuilder('Cake\ORM\Table')
->setMethods(['saveAssociated', 'schema'])
->setConstructorArgs([['table' => 'tags', 'connection' => $connection]])
->getMock();
$mock->primaryKey('id');
$config = [
@@ -908,7 +915,9 @@ public function testPropertyOption()
*/
public function testPropertyNoPlugin()
{
$mock = $this->getMock('Cake\ORM\Table', [], [], '', false);
$mock = $this->getMockBuilder('Cake\ORM\Table')
->disableOriginalConstructor()
->getMock();
$config = [
'sourceTable' => $this->article,
'targetTable' => $mock,
@@ -265,7 +265,9 @@ public function testAttachToMultiPrimaryKeyMistmatch()
*/
public function testCascadeDelete()
{
$mock = $this->getMock('Cake\ORM\Table', [], [], '', false);
$mock = $this->getMockBuilder('Cake\ORM\Table')
->disableOriginalConstructor()
->getMock();
$config = [
'sourceTable' => $this->client,
'targetTable' => $mock,
@@ -287,7 +289,10 @@ public function testCascadeDelete()
*/
public function testSaveAssociatedOnlyEntities()
{
$mock = $this->getMock('Cake\ORM\Table', ['saveAssociated'], [], '', false);
$mock = $this->getMockBuilder('Cake\ORM\Table')
->setMethods(['saveAssociated'])
->disableOriginalConstructor()
->getMock();
$config = [
'sourceTable' => $this->client,
'targetTable' => $mock,
@@ -326,7 +331,9 @@ public function testPropertyOption()
*/
public function testPropertyNoPlugin()
{
$mock = $this->getMock('Cake\ORM\Table', [], [], '', false);
$mock = $this->getMockBuilder('Cake\ORM\Table')
->disableOriginalConstructor()
->getMock();
$config = [
'sourceTable' => $this->client,
'targetTable' => $mock,
@@ -348,7 +355,9 @@ public function testAttachToBeforeFind()
'sourceTable' => $this->client,
'targetTable' => $this->company
];
$listener = $this->getMock('stdClass', ['__invoke']);
$listener = $this->getMockBuilder('stdClass')
->setMethods(['__invoke'])
->getMock();
$this->company->eventManager()->attach($listener, 'Model.beforeFind');
$association = new BelongsTo('Companies', $config);
$listener->expects($this->once())->method('__invoke')
@@ -374,7 +383,9 @@ public function testAttachToBeforeFindExtraOptions()
'sourceTable' => $this->client,
'targetTable' => $this->company
];
$listener = $this->getMock('stdClass', ['__invoke']);
$listener = $this->getMockBuilder('stdClass')
->setMethods(['__invoke'])
->getMock();
$this->company->eventManager()->attach($listener, 'Model.beforeFind');
$association = new BelongsTo('Companies', $config);
$options = new \ArrayObject(['something' => 'more']);
@@ -57,11 +57,10 @@ public function setUp()
]
]);
$connection = ConnectionManager::get('test');
$this->article = $this->getMock(
'Cake\ORM\Table',
['find', 'deleteAll', 'delete'],
[['alias' => 'Articles', 'table' => 'articles', 'connection' => $connection]]
);
$this->article = $this->getMockBuilder('Cake\ORM\Table')
->setMethods(['find', 'deleteAll', 'delete'])
->setConstructorArgs([['alias' => 'Articles', 'table' => 'articles', 'connection' => $connection]])
->getMock();
$this->article->schema([
'id' => ['type' => 'integer'],
'title' => ['type' => 'string'],
@@ -388,7 +387,10 @@ public function testEagerLoaderMultipleKeys()
$this->author->primaryKey(['id', 'site_id']);
$association = new HasMany('Articles', $config);
$keys = [[1, 10], [2, 20], [3, 30], [4, 40]];
$query = $this->getMock('Cake\ORM\Query', ['all', 'andWhere'], [null, null]);
$query = $this->getMockBuilder('Cake\ORM\Query')
->setMethods(['all', 'andWhere'])
->setConstructorArgs([null, null])
->getMock();
$this->article->method('find')
->with('all')
->will($this->returnValue($query));
@@ -486,7 +488,10 @@ public function testCascadeDeleteCallbacks()
*/
public function testSaveAssociatedOnlyEntities()
{
$mock = $this->getMock('Cake\ORM\Table', ['saveAssociated'], [], '', false);
$mock = $this->getMockBuilder('Cake\ORM\Table')
->setMethods(['saveAssociated'])
->disableOriginalConstructor()
->getMock();
$config = [
'sourceTable' => $this->author,
'targetTable' => $mock,
@@ -527,7 +532,9 @@ public function testPropertyOption()
*/
public function testPropertyNoPlugin()
{
$mock = $this->getMock('Cake\ORM\Table', [], [], '', false);
$mock = $this->getMockBuilder('Cake\ORM\Table')
->disableOriginalConstructor()
->getMock();
$config = [
'sourceTable' => $this->author,
'targetTable' => $mock,
Oops, something went wrong.

0 comments on commit 197d2d7

Please sign in to comment.
You can’t perform that action at this time.