Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/jsxc.nextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLEDfan <tobia@ledfan.be>2016-01-17 13:18:41 +0300
committerLEDfan <tobia@ledfan.be>2016-01-17 13:18:41 +0300
commitedca62d2fb1c4824aaaa07d56c799e8ff7f0c1ba (patch)
treee80c96bc80e83f7b9d59727543a52869c220ce4a /utility/mappertestutility.php
parente9c2976d2af317f25c7945ba84d74519318f72f5 (diff)
More unit and integration tests
Diffstat (limited to 'utility/mappertestutility.php')
-rw-r--r--utility/mappertestutility.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/utility/mappertestutility.php b/utility/mappertestutility.php
new file mode 100644
index 0000000..0a705ce
--- /dev/null
+++ b/utility/mappertestutility.php
@@ -0,0 +1,46 @@
+<?php
+
+namespace OCA\OJSXC\Utility;
+
+use Test\TestCase;
+use OCA\OJSXC\AppInfo\Application;
+
+
+/**
+ * @group DB
+ */
+class MapperTestUtility extends TestCase {
+
+ /**
+ * @var \OCP\AppFramework\IAppContainer
+ */
+ protected $container;
+
+ protected $entityName;
+
+ protected $mapperName;
+
+ protected function setUp() {
+ parent::setUp();
+ $app = new Application();
+ $this->container = $app->getContainer();
+ $this->mapper = $this->container[$this->mapperName];
+
+ $con = $this->container->getServer()->getDatabaseConnection();
+ $con->executeQuery('DELETE FROM ' . $this->mapper->getTableName());
+ }
+
+ protected function fetchAll(){
+ $con = $this->container->getServer()->getDatabaseConnection();
+ $stmt = $con->executeQuery('SELECT * FROM ' . $this->mapper->getTableName());
+ $entities = [];
+
+ while($row = $stmt->fetch()){
+ $entities[] = call_user_func($this->entityName . '::fromRow', $row);;
+ }
+
+ $stmt->closeCursor();
+
+ return $entities;
+ }
+} \ No newline at end of file