summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Cornutt <chris.cornutt@hp.com>2015-01-15 11:02:40 -0600
committerChris Cornutt <chris.cornutt@hp.com>2015-01-15 11:02:40 -0600
commitc7d38a8ec25eb0c6a132ca34a91abac090820c6f (patch)
tree3ab71535b757d2d196a39e01c97888e8ccd3a0fa
parentac5254f6c39f5e400c3d49a59553156e5990d9bc (diff)
downloadgatekeeper-c7d38a8ec25eb0c6a132ca34a91abac090820c6f.zip
gatekeeper-c7d38a8ec25eb0c6a132ca34a91abac090820c6f.tar.gz
gatekeeper-c7d38a8ec25eb0c6a132ca34a91abac090820c6f.tar.bz2
adding tests for get/set db, getting table name
-rw-r--r--tests/Psecio/Gatekeeper/DataSource/MysqlTest.php35
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