diff options
Diffstat (limited to 'tests/Psecio/Gatekeeper/DataSource/MysqlTest.php')
-rw-r--r-- | tests/Psecio/Gatekeeper/DataSource/MysqlTest.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/Psecio/Gatekeeper/DataSource/MysqlTest.php b/tests/Psecio/Gatekeeper/DataSource/MysqlTest.php index 4893d40..d91f42c 100644 --- a/tests/Psecio/Gatekeeper/DataSource/MysqlTest.php +++ b/tests/Psecio/Gatekeeper/DataSource/MysqlTest.php @@ -3,6 +3,7 @@ namespace Psecio\Gatekeeper\DataSource; include_once __DIR__.'/../MockPdo.php'; +include_once __DIR__.'/../MockModel.php'; class MysqlTest extends \Psecio\Gatekeeper\Base { @@ -23,4 +24,38 @@ class MysqlTest extends \Psecio\Gatekeeper\Base $this->assertEquals($mysql->getDb(), $pdo); } + + /** + * Test the getter/setter of the DB instance + * (just uses a basic object) + */ + public function testGetSetDatabaseInstance() + { + $mysql = $this->getMockBuilder('\Psecio\Gatekeeper\DataSource\Mysql') + ->disableOriginalConstructor() + ->setMethods(array('buildPdo')) + ->getMock(); + + $db = (object)array('test' => 'foo'); + $mysql->setDb($db); + + $this->assertEquals($mysql->getDb(), $db); + } + + /** + * Test getting the table name for the model instance + */ + public function testGetTableName() + { + $config = array(); + $pdo = $this->getMockBuilder('\Psecio\Gatekeeper\MockPdo')->getMock(); + + $ds = $this->getMockBuilder('\Psecio\Gatekeeper\DataSource\Mysql') + ->setConstructorArgs(array($config, $pdo)) + ->setMethods(array('buildPdo')) + ->getMock(); + + $mysql = new \Psecio\Gatekeeper\MockModel($ds); + $this->assertEquals('test', $mysql->getTableName()); + } }
\ No newline at end of file |