Skip to content

Commit

Permalink
fix phpunit mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
antograssiot committed Aug 18, 2016
1 parent ad52e46 commit b204289
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 15 deletions.
18 changes: 10 additions & 8 deletions tests/TestCase/Controller/Component/AuthComponentTest.php
Expand Up @@ -14,6 +14,8 @@
*/
namespace Cake\Test\TestCase\Controller\Component;

use Cake\Auth\BaseAuthorize;
use Cake\Auth\FormAuthenticate;
use Cake\Controller\Component\AuthComponent;
use Cake\Core\Configure;
use Cake\Event\Event;
Expand Down Expand Up @@ -123,7 +125,7 @@ public function testIsErrorOrTests()
*/
public function testIdentify()
{
$AuthLoginFormAuthenticate = $this->getMockBuilder('Cake\Controller\Component\Auth\FormAuthenticate')
$AuthLoginFormAuthenticate = $this->getMockBuilder(FormAuthenticate::class)
->setMethods(['authenticate'])
->disableOriginalConstructor()
->getMock();
Expand Down Expand Up @@ -164,7 +166,7 @@ public function testIdentify()
*/
public function testIdentifyArrayAccess()
{
$AuthLoginFormAuthenticate = $this->getMockBuilder('Cake\Controller\Component\Auth\FormAuthenticate')
$AuthLoginFormAuthenticate = $this->getMockBuilder(FormAuthenticate::class)
->setMethods(['authenticate'])
->disableOriginalConstructor()
->getMock();
Expand Down Expand Up @@ -269,15 +271,15 @@ public function testIsAuthorizedMissingFile()
*/
public function testIsAuthorizedDelegation()
{
$AuthMockOneAuthorize = $this->getMockBuilder('Cake\Controller\Component\BaseAuthorize')
$AuthMockOneAuthorize = $this->getMockBuilder(BaseAuthorize::class)
->setMethods(['authorize'])
->disableOriginalConstructor()
->getMock();
$AuthMockTwoAuthorize = $this->getMockBuilder('Cake\Controller\Component\BaseAuthorize')
$AuthMockTwoAuthorize = $this->getMockBuilder(BaseAuthorize::class)
->setMethods(['authorize'])
->disableOriginalConstructor()
->getMock();
$AuthMockThreeAuthorize = $this->getMockBuilder('Cake\Controller\Component\BaseAuthorize')
$AuthMockThreeAuthorize = $this->getMockBuilder(BaseAuthorize::class)
->setMethods(['authorize'])
->disableOriginalConstructor()
->getMock();
Expand Down Expand Up @@ -311,7 +313,7 @@ public function testIsAuthorizedDelegation()
*/
public function testIsAuthorizedWithArrayObject()
{
$AuthMockOneAuthorize = $this->getMockBuilder('Cake\Controller\Component\BaseAuthorize')
$AuthMockOneAuthorize = $this->getMockBuilder(BaseAuthorize::class)
->setMethods(['authorize'])
->disableOriginalConstructor()
->getMock();
Expand All @@ -337,7 +339,7 @@ public function testIsAuthorizedWithArrayObject()
*/
public function testIsAuthorizedUsingUserInSession()
{
$AuthMockFourAuthorize = $this->getMockBuilder('Cake\Controller\Component\BaseAuthorize')
$AuthMockFourAuthorize = $this->getMockBuilder(BaseAuthorize::class)
->setMethods(['authorize'])
->disableOriginalConstructor()
->getMock();
Expand Down Expand Up @@ -728,7 +730,7 @@ public function testNoLoginRedirectForAuthenticatedUser()

$this->Auth->session->write('Auth.User.id', '1');
$this->Auth->config('authenticate', ['Form']);
$this->getMockBuilder('Cake\Controller\Component\BaseAuthorize')
$this->getMockBuilder(BaseAuthorize::class)
->setMethods(['authorize'])
->disableOriginalConstructor()
->setMockClassName('NoLoginRedirectMockAuthorize')
Expand Down
3 changes: 2 additions & 1 deletion tests/TestCase/Database/ConnectionTest.php
Expand Up @@ -16,6 +16,7 @@

use Cake\Core\Configure;
use Cake\Database\Connection;
use Cake\Database\Driver\Mysql;
use Cake\Datasource\ConnectionManager;
use Cake\TestSuite\TestCase;

Expand Down Expand Up @@ -113,7 +114,7 @@ public function testMissingDriver()
*/
public function testDisabledDriver()
{
$mock = $this->getMockBuilder('\Cake\Database\Connection\Driver')
$mock = $this->getMockBuilder(Mysql::class)
->setMethods(['enabled'])
->setMockClassName('DriverMock')
->getMock();
Expand Down
3 changes: 2 additions & 1 deletion tests/TestCase/Database/Driver/SqliteTest.php
Expand Up @@ -127,8 +127,9 @@ public static function schemaValueProvider()
public function testSchemaValue($input, $expected)
{
$driver = new Sqlite();
$mock = $this->getMockBuilder('FakePdo')
$mock = $this->getMockBuilder(\PDO::class)
->setMethods(['quote', 'quoteIdentifier'])
->disableOriginalConstructor()
->getMock();
$mock->expects($this->any())
->method('quote')
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Database/DriverTest.php
Expand Up @@ -15,7 +15,7 @@
namespace Cake\Test\TestCase\Database;

use Cake\Database\Driver;
use Cake\Database\Mysql;
use Cake\Database\Driver\Mysql;
use Cake\Database\Query;
use Cake\Database\QueryCompiler;
use Cake\Database\ValueBinder;
Expand Down
3 changes: 2 additions & 1 deletion tests/TestCase/Database/Schema/MysqlSchemaTest.php
Expand Up @@ -1229,8 +1229,9 @@ public function testDescribeJson()
protected function _getMockedDriver()
{
$driver = new \Cake\Database\Driver\Mysql();
$mock = $this->getMockBuilder('FakePdo')
$mock = $this->getMockBuilder(\PDO::class)
->setMethods(['quote', 'quoteIdentifier', 'getAttribute'])
->disableOriginalConstructor()
->getMock();
$mock->expects($this->any())
->method('quote')
Expand Down
3 changes: 2 additions & 1 deletion tests/TestCase/Database/Schema/PostgresSchemaTest.php
Expand Up @@ -1197,8 +1197,9 @@ public function testTruncateSql()
protected function _getMockedDriver()
{
$driver = new \Cake\Database\Driver\Postgres();
$mock = $this->getMockBuilder('FakePdo')
$mock = $this->getMockBuilder(\PDO::class)
->setMethods(['quote'])
->disableOriginalConstructor()
->getMock();
$mock->expects($this->any())
->method('quote')
Expand Down
3 changes: 2 additions & 1 deletion tests/TestCase/Database/Schema/SqliteSchemaTest.php
Expand Up @@ -1030,8 +1030,9 @@ public function testTruncateSqlNoSequences()
protected function _getMockedDriver()
{
$driver = new \Cake\Database\Driver\Sqlite();
$mock = $this->getMockBuilder('FakePdo')
$mock = $this->getMockBuilder(\PDO::class)
->setMethods(['quote', 'prepare'])
->disableOriginalConstructor()
->getMock();
$mock->expects($this->any())
->method('quote')
Expand Down
3 changes: 2 additions & 1 deletion tests/TestCase/Database/Schema/SqlserverSchemaTest.php
Expand Up @@ -950,8 +950,9 @@ public function testTruncateSql()
protected function _getMockedDriver()
{
$driver = new \Cake\Database\Driver\Sqlserver();
$mock = $this->getMockBuilder('FakePdo')
$mock = $this->getMockBuilder(\PDO::class)
->setMethods(['quote'])
->disableOriginalConstructor()
->getMock();
$mock->expects($this->any())
->method('quote')
Expand Down

0 comments on commit b204289

Please sign in to comment.