1
0
mirror of synced 2024-12-15 07:36:03 +03:00
doctrine2/tests/lib/mocks/Doctrine_ConnectionMock.php

80 lines
1.5 KiB
PHP
Raw Normal View History

<?php
2009-01-04 19:15:32 +03:00
#namespace Doctrine\Tests\Mocks;
#use Doctrine\DBAL\Connection;
require_once 'lib/mocks/Doctrine_SequenceMock.php';
require_once 'lib/mocks/Doctrine_DatabasePlatformMock.php';
2008-09-12 21:25:38 +04:00
class Doctrine_ConnectionMock extends Doctrine_DBAL_Connection
{
private $_platformMock;
2008-09-07 17:48:40 +04:00
private $_lastInsertId = 0;
2008-08-16 23:40:59 +04:00
private $_inserts = array();
2008-09-12 21:25:38 +04:00
public function __construct() {
$this->_platformMock = new Doctrine_DatabasePlatformMock();
$this->_platform = $this->_platformMock;
}
/**
* @override
*/
2008-09-07 17:48:40 +04:00
public function getDatabasePlatform()
{
2008-09-07 17:48:40 +04:00
return $this->_platformMock;
}
/**
* @override
*/
2008-09-07 17:48:40 +04:00
public function insert($tableName, array $data)
{
2008-09-07 17:48:40 +04:00
$this->_inserts[$tableName][] = $data;
}
2008-08-16 23:40:59 +04:00
/**
* @override
*/
2008-09-07 17:48:40 +04:00
public function lastInsertId($seqName = null)
2008-08-16 23:40:59 +04:00
{
2008-09-07 17:48:40 +04:00
return $this->_lastInsertId;
}
/**
* @override
*/
public function quote($input, $type = null)
{
if ($type === 'string') {
return "'" . $input . "'";
}
return $input;
2008-08-16 23:40:59 +04:00
}
/* Mock API */
public function setDatabasePlatform($platform)
{
$this->_platformMock = $platform;
}
2008-09-07 17:48:40 +04:00
public function setLastInsertId($id)
{
2008-09-07 17:48:40 +04:00
$this->_lastInsertId = $id;
}
2008-08-16 23:40:59 +04:00
public function getInserts()
{
return $this->_inserts;
}
public function reset()
{
$this->_inserts = array();
2008-09-07 17:48:40 +04:00
$this->_lastInsertId = 0;
2008-08-16 23:40:59 +04:00
}
}