Skip to content
Permalink
Browse files

Fix getMock() deprecations in TestSuite.

Only the ORM remains.
  • Loading branch information...
markstory committed Jun 6, 2016
1 parent 49906d8 commit 494c848751e48c20acae1c650133e1d72c08f237
Showing with 62 additions and 25 deletions.
  1. +50 −21 tests/TestCase/TestSuite/TestFixtureTest.php
  2. +12 −4 tests/TestCase/TestSuite/TestSuiteTest.php
@@ -299,7 +299,10 @@ public function testInitNoImportNoFields()
$fixture->init();
$this->assertEquals(['id', 'letter'], $fixture->schema()->columns());
$db = $this->getMock('Cake\Database\Connection', ['prepare', 'execute'], [], '', false);
$db = $this->getMockBuilder('Cake\Database\Connection')
->setMethods(['prepare', 'execute'])
->disableOriginalConstructor()
->getMock();
$db->expects($this->never())
->method('prepare');
$db->expects($this->never())
@@ -316,15 +319,19 @@ public function testInitNoImportNoFields()
public function testCreate()
{
$fixture = new ArticlesFixture();
$db = $this->getMock('Cake\Database\Connection', [], [], '', false);
$table = $this->getMock('Cake\Database\Schema\Table', [], ['articles']);
$db = $this->createMock('Cake\Database\Connection');
$table = $this->getMockBuilder('Cake\Database\Schema\Table')
->setConstructorArgs(['articles'])
->getMock();
$table->expects($this->once())
->method('createSql')
->with($db)
->will($this->returnValue(['sql', 'sql']));
$fixture->schema($table);
$statement = $this->getMock('\PDOStatement', ['execute', 'closeCursor']);
$statement = $this->getMockBuilder('\PDOStatement')
->setMethods(['execute', 'closeCursor'])
->getMock();
$statement->expects($this->atLeastOnce())->method('closeCursor');
$statement->expects($this->atLeastOnce())->method('execute');
$db->expects($this->exactly(2))
@@ -342,8 +349,10 @@ public function testCreate()
public function testCreateError()
{
$fixture = new ArticlesFixture();
$db = $this->getMock('Cake\Database\Connection', [], [], '', false);
$table = $this->getMock('Cake\Database\Schema\Table', [], ['articles']);
$db = $this->createMock('Cake\Database\Connection');
$table = $this->getMockBuilder('Cake\Database\Schema\Table')
->setConstructorArgs(['articles'])
->getMock();
$table->expects($this->once())
->method('createSql')
->with($db)
@@ -362,8 +371,10 @@ public function testInsert()
{
$fixture = new ArticlesFixture();
$db = $this->getMock('Cake\Database\Connection', [], [], '', false);
$query = $this->getMock('Cake\Database\Query', [], [$db]);
$db = $this->createMock('Cake\Database\Connection');
$query = $this->getMockBuilder('Cake\Database\Query')
->setConstructorArgs([$db])
->getMock();
$db->expects($this->once())
->method('newQuery')
->will($this->returnValue($query));
@@ -396,7 +407,9 @@ public function testInsert()
->with($expected[2])
->will($this->returnSelf());
$statement = $this->getMock('\PDOStatement', ['closeCursor']);
$statement = $this->getMockBuilder('\PDOStatement')
->setMethods(['closeCursor'])
->getMock();
$statement->expects($this->once())->method('closeCursor');
$query->expects($this->once())
->method('execute')
@@ -414,8 +427,10 @@ public function testInsertImport()
{
$fixture = new ImportsFixture();
$db = $this->getMock('Cake\Database\Connection', [], [], '', false);
$query = $this->getMock('Cake\Database\Query', [], [$db]);
$db = $this->createMock('Cake\Database\Connection');
$query = $this->getMockBuilder('Cake\Database\Query')
->setConstructorArgs([$db])
->getMock();
$db->expects($this->once())
->method('newQuery')
->will($this->returnValue($query));
@@ -438,7 +453,9 @@ public function testInsertImport()
->with($expected[0])
->will($this->returnSelf());
$statement = $this->getMock('\PDOStatement', ['closeCursor']);
$statement = $this->getMockBuilder('\PDOStatement')
->setMethods(['closeCursor'])
->getMock();
$statement->expects($this->once())->method('closeCursor');
$query->expects($this->once())
->method('execute')
@@ -456,8 +473,10 @@ public function testInsertStrings()
{
$fixture = new StringsTestsFixture();
$db = $this->getMock('Cake\Database\Connection', [], [], '', false);
$query = $this->getMock('Cake\Database\Query', [], [$db]);
$db = $this->createMock('Cake\Database\Connection');
$query = $this->getMockBuilder('Cake\Database\Query')
->setConstructorArgs([$db])
->getMock();
$db->expects($this->once())
->method('newQuery')
->will($this->returnValue($query));
@@ -490,7 +509,9 @@ public function testInsertStrings()
->with($expected[2])
->will($this->returnSelf());
$statement = $this->getMock('\PDOStatement', ['closeCursor']);
$statement = $this->getMockBuilder('\PDOStatement')
->setMethods(['closeCursor'])
->getMock();
$statement->expects($this->once())->method('closeCursor');
$query->expects($this->once())
->method('execute')
@@ -508,14 +529,18 @@ public function testDrop()
{
$fixture = new ArticlesFixture();
$db = $this->getMock('Cake\Database\Connection', [], [], '', false);
$statement = $this->getMock('\PDOStatement', ['closeCursor']);
$db = $this->createMock('Cake\Database\Connection');
$statement = $this->getMockBuilder('\PDOStatement')
->setMethods(['closeCursor'])
->getMock();
$statement->expects($this->once())->method('closeCursor');
$db->expects($this->once())->method('execute')
->with('sql')
->will($this->returnValue($statement));
$table = $this->getMock('Cake\Database\Schema\Table', [], ['articles']);
$table = $this->getMockBuilder('Cake\Database\Schema\Table')
->setConstructorArgs(['articles'])
->getMock();
$table->expects($this->once())
->method('dropSql')
->with($db)
@@ -534,14 +559,18 @@ public function testTruncate()
{
$fixture = new ArticlesFixture();
$db = $this->getMock('Cake\Database\Connection', [], [], '', false);
$statement = $this->getMock('\PDOStatement', ['closeCursor']);
$db = $this->createMock('Cake\Database\Connection');
$statement = $this->getMockBuilder('\PDOStatement')
->setMethods(['closeCursor'])
->getMock();
$statement->expects($this->once())->method('closeCursor');
$db->expects($this->once())->method('execute')
->with('sql')
->will($this->returnValue($statement));
$table = $this->getMock('Cake\Database\Schema\Table', [], ['articles']);
$table = $this->getMockBuilder('Cake\Database\Schema\Table')
->setConstructorArgs(['articles'])
->getMock();
$table->expects($this->once())
->method('truncateSql')
->with($db)
@@ -34,7 +34,9 @@ public function testAddTestDirectory()
$testFolder = CORE_TEST_CASES . DS . 'TestSuite';
$count = count(glob($testFolder . DS . '*Test.php'));
$suite = $this->getMock('Cake\TestSuite\TestSuite', ['addTestFile']);
$suite = $this->getMockBuilder('Cake\TestSuite\TestSuite')
->setMethods(['addTestFile'])
->getMock();
$suite
->expects($this->exactly($count))
->method('addTestFile');
@@ -53,7 +55,9 @@ public function testAddTestDirectoryRecursive()
$count = count(glob($testFolder . DS . '*Test.php'));
$count += count(glob($testFolder . DS . 'Engine/*Test.php'));
$suite = $this->getMock('Cake\TestSuite\TestSuite', ['addTestFile']);
$suite = $this->getMockBuilder('Cake\TestSuite\TestSuite')
->setMethods(['addTestFile'])
->getMock();
$suite
->expects($this->exactly($count))
->method('addTestFile');
@@ -76,7 +80,9 @@ public function testAddTestDirectoryRecursiveWithHidden()
touch($Folder->path . DS . 'NotHiddenTest.php');
touch($Folder->path . DS . '.HiddenTest.php');
$suite = $this->getMock('Cake\TestSuite\TestSuite', ['addTestFile']);
$suite = $this->getMockBuilder('Cake\TestSuite\TestSuite')
->setMethods(['addTestFile'])
->getMock();
$suite
->expects($this->exactly(1))
->method('addTestFile');
@@ -100,7 +106,9 @@ public function testAddTestDirectoryRecursiveWithNonPhp()
touch($Folder->path . DS . 'SomeNotesTest.txt');
touch($Folder->path . DS . 'NotHiddenTest.php');
$suite = $this->getMock('Cake\TestSuite\TestSuite', ['addTestFile']);
$suite = $this->getMockBuilder('Cake\TestSuite\TestSuite')
->setMethods(['addTestFile'])
->getMock();
$suite
->expects($this->exactly(1))
->method('addTestFile');

0 comments on commit 494c848

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