From 76b3dcd712b9bce4b94be58a07c8dbe584ee8f2f Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Fri, 5 Apr 2013 11:01:37 +0200 Subject: small work on integration test --- tests/integration/db/ItemMapperIntegrationTest.php | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 tests/integration/db/ItemMapperIntegrationTest.php (limited to 'tests/integration') diff --git a/tests/integration/db/ItemMapperIntegrationTest.php b/tests/integration/db/ItemMapperIntegrationTest.php new file mode 100644 index 000000000..7f4bb2c40 --- /dev/null +++ b/tests/integration/db/ItemMapperIntegrationTest.php @@ -0,0 +1,81 @@ +. +* +*/ + +namespace OCA\News\Db; + +use \OCA\AppFramework\Utility\MapperTestUtility; + +require_once(__DIR__ . "/../../classloader.php"); + + +class InMemoryDatabase { + + private $db; + + public function __construct(){ + $this->db = new \PDO('sqlite::memory:'); + } + + + public function prepare($sql){ + $count = 1; + $sql = str_replace('*PREFIX*', 'oc', $sql, $count); + var_dump($this->db->prepare($sql)); + return $this->db->prepare($sql); + } + + +} + + + +class ItemMapperIntegrationTest extends MapperTestUtility { + + protected $api; + + private $mapper; + private $db; + + protected function setUp(){ + $db = new InMemoryDatabase(); + $prepare = function($sql) use ($db){ + return $db->prepare($sql); + }; + + $this->api = $this->getMock('OCA\AppFramework\Core\API', + array('prepareQuery', 'getInsertId'), array('news')); + $this->api->expects($this->any()) + ->method('prepareQuery') + ->will($this->returnCallback($prepare)); + $this->mapper = new ItemMapper($this->api); + } + + + public function testFind(){ + //$this->mapper->find(3, 'john'); + } + + +} \ No newline at end of file -- cgit v1.2.3