Skip to content
This repository
Browse code

Enhance test environment

=> run make test to run all tests

- forward Erfurt submodule
  • Loading branch information...
commit 5a2a632e30bde17fc6a02c7439e59266e5929871 1 parent 32aa515
Philipp Frischmuth authored September 10, 2012
45  Makefile
@@ -68,10 +68,14 @@ help-cs:
68 68
 	@echo "     > OPTIONS=<option> ............. Run code checking with specific CodeSniffer options"
69 69
 
70 70
 help-test:
71  
-	@echo "     test ....................... Execute unit and integration tests"
72  
-	@echo "     test-unit .................. Run OntoWiki unit tests"
73  
-	@echo "     test-integration ........... Run OntoWiki integration tests"
74  
-	@echo "     test-extensions ............ Run tests for extensions"
  71
+	@echo "  test ......................... Execute unit, integration and extension tests"
  72
+	@echo "  test-unit .................... Run OntoWiki unit tests"
  73
+	@echo "  test-unit-cc ................. Same as above plus code coverage report"
  74
+	@echo "  test-integration-virtuoso .... Run OntoWiki integration tests with virtuoso"
  75
+	@echo "  test-integration-virtuoso-cc . Same as above plus code coverage report"
  76
+	@echo "  test-integration-mysql ....... Run OntoWiki integration tests with mysql"
  77
+	@echo "  test-integration-mysql-cc .... Same as above plus code coverage report"
  78
+	@echo "  test-extensions .............. Run tests for extensions"
75 79
 
76 80
 # top level target
77 81
 
@@ -160,21 +164,42 @@ rdfauthor:
160 164
 
161 165
 # test stuff
162 166
 
163  
-test-unit:
  167
+test-unit: directories
  168
+	@cd application/tests && phpunit --bootstrap Bootstrap.php unit/
  169
+
  170
+test-unit-cc: directories
164 171
 	@cd application/tests/unit && phpunit
165 172
 
166  
-test-integration:
167  
-	@cd application/tests/integration && phpunit
  173
+test-integration-virtuoso: directories
  174
+	@cd application/tests && EF_STORE_ADAPTER=virtuoso phpunit --bootstrap Bootstrap.php integration/
  175
+
  176
+test-integration-virtuoso-cc: directories
  177
+	@cd application/tests/integration && EF_STORE_ADAPTER=virtuoso phpunit
  178
+
  179
+test-integration-mysql: directories
  180
+	@cd application/tests && EF_STORE_ADAPTER=zenddb phpunit --bootstrap Bootstrap.php integration/
168 181
 
169  
-test-extensions:
  182
+test-integration-mysql-cc: directories
  183
+	@cd application/tests/integration && EF_STORE_ADAPTER=zenddb phpunit
  184
+
  185
+test-extensions: directories
170 186
 	@phpunit --bootstrap application/tests/Bootstrap.php extensions
171 187
 
172 188
 test:
173  
-	@make test-unit
  189
+	make test-unit
174 190
 	@echo ""
175 191
 	@echo "-----------------------------------"
176 192
 	@echo ""
177  
-	@make test-integration
  193
+	make test-integration-virtuoso
  194
+	@echo ""
  195
+	@echo "-----------------------------------"
  196
+	@echo ""
  197
+	make test-integration-mysql
  198
+	@echo ""
  199
+	@echo "-----------------------------------"
  200
+	@echo ""
  201
+	make test-extensions
  202
+
178 203
 
179 204
 install-test-environment:
180 205
 	sudo apt-get install php-pear
2  application/Bootstrap.php
@@ -94,6 +94,8 @@ public function _initExtensionManager()
94 94
         // actionhelper
95 95
         Zend_Controller_Action_HelperBroker::addPrefix('OntoWiki_Controller_ActionHelper_');
96 96
         Zend_Controller_Action_HelperBroker::addHelper(new OntoWiki_Controller_ActionHelper_List());
  97
+
  98
+        return $extensionManager;
97 99
     }
98 100
 
99 101
     /**
106  application/classes/OntoWiki/Test/ControllerTestCase.php
... ...
@@ -0,0 +1,106 @@
  1
+<?php
  2
+/**
  3
+ * Created by JetBrains PhpStorm.
  4
+ * User: philipp
  5
+ * Date: 08.09.12
  6
+ * Time: 14:59
  7
+ * To change this template use File | Settings | File Templates.
  8
+ */
  9
+class OntoWiki_Test_ControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase
  10
+{
  11
+    /** @var Erfurt_Ac_Test|Erfurt_Ac_Default */
  12
+    protected $_ac = null;
  13
+
  14
+    /** @var Erfurt_Store_Adapter_Interface */
  15
+    protected $_storeAdapter = null;
  16
+
  17
+    /** @var string|null */
  18
+    protected $_extensionName = null;
  19
+
  20
+    public function setUpIntegrationTest()
  21
+    {
  22
+        $this->bootstrap = new Zend_Application(
  23
+            'integration_testing',
  24
+            ONTOWIKI_ROOT . 'application/config/application.ini'
  25
+        );
  26
+
  27
+        try {
  28
+            parent::setUp();
  29
+        } catch (Exception $e) {
  30
+            // if we can't connect to the database, we skip the test
  31
+            $this->markTestSkipped($e->getMessage());
  32
+        }
  33
+
  34
+        // additional checks for database....
  35
+        $this->_markTestNeedsDatabase();
  36
+    }
  37
+
  38
+    public function setUpUnitTest()
  39
+    {
  40
+        $this->bootstrap = new Zend_Application(
  41
+            'unit_testing',
  42
+            ONTOWIKI_ROOT . 'application/config/application.ini'
  43
+        );
  44
+
  45
+        parent::setUp();
  46
+    }
  47
+
  48
+    public function setUpExtensionUnitTest()
  49
+    {
  50
+        $this->bootstrap = new Zend_Application(
  51
+            'extension_unit_testing',
  52
+            ONTOWIKI_ROOT . 'application/config/application.ini'
  53
+        );
  54
+        parent::setUp();
  55
+
  56
+        if (null !== $this->_extensionName) {
  57
+            $extensionManager = OntoWiki::getInstance()->extensionManager;
  58
+
  59
+            if (!$extensionManager->isExtensionActive($this->_extensionName)) {
  60
+                Erfurt_Event_Dispatcher::reset();
  61
+                $this->markTestSkipped('extension is not active');
  62
+            }
  63
+        }
  64
+
  65
+        $this->_ac = Erfurt_App::getInstance(false)->getAc();
  66
+        $this->_storeAdapter = Erfurt_App::getInstance(false)->getStore()->getBackendAdapter();
  67
+    }
  68
+
  69
+    private function _markTestNeedsDatabase()
  70
+    {
  71
+        $config =  Erfurt_App::getInstance(false)->getConfig();
  72
+
  73
+        $dbName = null;
  74
+        if ($config->store->backend === 'virtuoso') {
  75
+            if (isset($config->store->virtuoso->dsn)) {
  76
+                $dbName = $config->store->virtuoso->dsn;
  77
+            }
  78
+        } else if ($config->store->backend === 'zenddb') {
  79
+            if (isset($config->store->zenddb->dbname)) {
  80
+                $dbName = $config->store->zenddb->dbname;
  81
+            }
  82
+        }
  83
+
  84
+        if ((null === $dbName) || (substr($dbName, -5) !== '_TEST')) {
  85
+            $this->markTestSkipped('Invalid test database for tests: ' . $dbName); // make sure a test db was selected!
  86
+        }
  87
+
  88
+        try {
  89
+            $store = Erfurt_App::getInstance(false)->getStore();
  90
+            $store->checkSetup();
  91
+            $this->_dbWasUsed = true;
  92
+        } catch (Erfurt_Store_Exception $e) {
  93
+            if ($e->getCode() === 20) {
  94
+                // Setup successful
  95
+                $this->_dbWasUsed = true;
  96
+            } else {
  97
+                $this->markTestSkipped();
  98
+            }
  99
+        } catch (Erfurt_Exception $e2) {
  100
+            $this->markTestSkipped();
  101
+        }
  102
+
  103
+        $this->assertTrue(Erfurt_App::getInstance()->getStore()->isModelAvailable($config->sysont->modelUri, false));
  104
+        $this->assertTrue(Erfurt_App::getInstance()->getStore()->isModelAvailable($config->sysont->schemaUri, false));
  105
+    }
  106
+}
67  application/classes/OntoWiki/Test/ExtensionUnitTestBootstrap.php
... ...
@@ -0,0 +1,67 @@
  1
+<?php
  2
+require_once realpath(dirname(dirname(dirname(dirname(__FILE__))))). DIRECTORY_SEPARATOR . 'Bootstrap.php';
  3
+
  4
+/**
  5
+ * This file is part of the {@link http://ontowiki.net OntoWiki} project.
  6
+ *
  7
+ * @copyright Copyright (c) 2012, {@link http://aksw.org AKSW}
  8
+ * @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
  9
+ */
  10
+
  11
+/**
  12
+ * OntoWiki bootstrap class.
  13
+ *
  14
+ * Provides on-demand loading of application resources.
  15
+ *
  16
+ * @category OntoWiki
  17
+ * @package OntoWiki_Bootstrap
  18
+ * @copyright Copyright (c) 2012, {@link http://aksw.org AKSW}
  19
+ * @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
  20
+ * @author Philipp Frischmuth <pfrischmuth@googlemail.com>
  21
+ */
  22
+class OntoWiki_Test_ExtensionUnitTestBootstrap extends Bootstrap
  23
+{
  24
+    public function _initErfurt()
  25
+    {
  26
+        $erfurt = null;
  27
+
  28
+        // require Config
  29
+        $this->bootstrap('Config');
  30
+        $config = $this->getResource('Config');
  31
+
  32
+        // require OntoWiki
  33
+        $this->bootstrap('OntoWiki');
  34
+        $ontoWiki = $this->getResource('OntoWiki');
  35
+
  36
+        // require Logger, since Erfurt logger should write into OW logs dir
  37
+        $this->bootstrap('Logger');
  38
+
  39
+        // Reset the Erfurt app for testability... needs to be refactored.
  40
+        Erfurt_App::reset();
  41
+
  42
+        try {
  43
+            $erfurt = Erfurt_App::getInstance(false)->start($config);
  44
+        } catch (Erfurt_Exception $ee) {
  45
+            throw new OntoWiki_Exception('Error loading Erfurt framework: ' . $ee->getMessage());
  46
+        } catch (Exception $e) {
  47
+            throw new OntoWiki_Exception('Unexpected error: ' . $e->getMessage());
  48
+        }
  49
+
  50
+        $testAdapter = new Erfurt_Store_Adapter_Test();
  51
+        $store = new Erfurt_Store(
  52
+            array(
  53
+                 'adapterInstance' => $testAdapter
  54
+            ),
  55
+            'Test'
  56
+        );
  57
+        $erfurt->setStore($store);
  58
+
  59
+        $testAc = new Erfurt_Ac_Test();
  60
+        Erfurt_App::getInstance()->setAc($testAc);
  61
+
  62
+        // make available
  63
+        $ontoWiki->erfurt = $erfurt;
  64
+
  65
+        return $erfurt;
  66
+    }
  67
+}
67  application/classes/OntoWiki/Test/IntegrationTestBootstrap.php
... ...
@@ -0,0 +1,67 @@
  1
+<?php
  2
+require_once realpath(dirname(dirname(dirname(dirname(__FILE__))))). DIRECTORY_SEPARATOR . 'Bootstrap.php';
  3
+
  4
+/**
  5
+ * This file is part of the {@link http://ontowiki.net OntoWiki} project.
  6
+ *
  7
+ * @copyright Copyright (c) 2012, {@link http://aksw.org AKSW}
  8
+ * @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
  9
+ */
  10
+
  11
+/**
  12
+ * OntoWiki bootstrap class.
  13
+ *
  14
+ * Provides on-demand loading of application resources.
  15
+ *
  16
+ * @category OntoWiki
  17
+ * @package OntoWiki_Bootstrap
  18
+ * @copyright Copyright (c) 2012, {@link http://aksw.org AKSW}
  19
+ * @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
  20
+ * @author Philipp Frischmuth <pfrischmuth@googlemail.com>
  21
+ */
  22
+class OntoWiki_Test_IntegrationTestBootstrap extends Bootstrap
  23
+{
  24
+    /**
  25
+     * Overwrite the config bootstrap method, such that the store backend can be set via an environment variable.
  26
+     *
  27
+     * @return void|Zend_Config_Ini
  28
+     */
  29
+    public function _initConfig()
  30
+    {
  31
+        $config = parent::_initConfig();
  32
+
  33
+        // Overwrite database settings from test config
  34
+        // load user application configuration files
  35
+        $tryDistConfig = false;
  36
+        try {
  37
+            $privateConfig = new Zend_Config_Ini(ONTOWIKI_ROOT . 'application/tests/config.ini', 'private', true);
  38
+            $config->merge($privateConfig);
  39
+        } catch (Zend_Config_Exception $e) {
  40
+            $tryDistConfig = true;
  41
+        }
  42
+
  43
+        if ($tryDistConfig === true) {
  44
+            try {
  45
+                $privateConfig = new Zend_Config_Ini(ONTOWIKI_ROOT . 'application/tests/config.ini.dist', 'private', true);
  46
+                $config->merge($privateConfig);
  47
+            } catch (Zend_Config_Exception $e) {
  48
+                $message = 'Failed to find test config';
  49
+                throw new OntoWiki_Exception($message);
  50
+            }
  51
+        }
  52
+
  53
+        // overwrite store adapter to use with environment variable if set
  54
+        // this is useful, when we want to test with different stores without manually
  55
+        // editing the config
  56
+        if ($config instanceof Zend_Config) {
  57
+            $storeAdapter = getenv('EF_STORE_ADAPTER');
  58
+            if (($storeAdapter === 'virtuoso') || ($storeAdapter === 'zenddb')) {
  59
+                $config->store->backend = $storeAdapter;
  60
+            } else if ($storeAdapter !== false) {
  61
+                throw new Exception('Invalid value of $EF_STORE_ADAPTER: ' . $storeAdapter);
  62
+            }
  63
+        }
  64
+
  65
+        return $config;
  66
+    }
  67
+}
4  application/tests/TestBootstrap.php → ...ation/classes/OntoWiki/Test/UnitTestBootstrap.php
... ...
@@ -1,5 +1,5 @@
1 1
 <?php
2  
-require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php'; 
  2
+require_once realpath(dirname(dirname(dirname(dirname(__FILE__))))). DIRECTORY_SEPARATOR . 'Bootstrap.php';
3 3
 
4 4
 /**
5 5
  * This file is part of the {@link http://ontowiki.net OntoWiki} project.
@@ -19,7 +19,7 @@
19 19
  * @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
20 20
  * @author Philipp Frischmuth <pfrischmuth@googlemail.com>
21 21
  */
22  
-class TestBootstrap extends Bootstrap
  22
+class OntoWiki_Test_UnitTestBootstrap extends Bootstrap
23 23
 {
24 24
     public function _initExtensionManager()
25 25
     {
14  application/config/application.ini
@@ -27,7 +27,15 @@ includePaths.classes = APPLICATION_PATH "classes"
27 27
 autoloaderNamespaces.ontoWiki = "OntoWiki_"
28 28
 autoloaderNamespaces.erfurt = "Erfurt_"
29 29
 
30  
-[testing : default]
31  
-bootstrap.path = APPLICATION_PATH "tests/TestBootstrap.php"
32  
-bootstrap.class = "TestBootstrap"
  30
+[unit_testing : default]
  31
+bootstrap.path = APPLICATION_PATH "classes/OntoWiki/Test/UnitTestBootstrap.php"
  32
+bootstrap.class = "OntoWiki_Test_UnitTestBootstrap"
  33
+
  34
+[integration_testing : default]
  35
+bootstrap.path = APPLICATION_PATH "classes/OntoWiki/Test/IntegrationTestBootstrap.php"
  36
+bootstrap.class = "OntoWiki_Test_IntegrationTestBootstrap"
  37
+
  38
+[extension_unit_testing : default]
  39
+bootstrap.path = APPLICATION_PATH "classes/OntoWiki/Test/ExtensionUnitTestBootstrap.php"
  40
+bootstrap.class = "OntoWiki_Test_ExtensionUnitTestBootstrap"
33 41
 
4  application/tests/config.ini.dist
@@ -7,8 +7,8 @@
7 7
 store.backend = zenddb ; zenddb, virtuoso, multi
8 8
 
9 9
 store.zenddb.dbname   = erfurt_TEST ; needs to end with _TEST
10  
-store.zenddb.username = ow
11  
-store.zenddb.password = ow
  10
+store.zenddb.username = php
  11
+store.zenddb.password = php
12 12
 store.zenddb.dbtype   = mysql     ; mysql
13 13
 ;store.zenddb.host     = localhost ; default is localhost
14 14
 
4  application/tests/integration/OntoWiki/Extension/ManagerIntegrationTest.php
@@ -13,10 +13,10 @@ protected function setUp()
13 13
     {
14 14
         $this->_resourcesDirectory = realpath(dirname(__FILE__)) . '/_files/';
15 15
 
16  
-        $this->markTestNeedsTestConfig();
  16
+        $this->markTestNeedsDatabase();
17 17
 
18 18
         $this->_bootstrap = new Zend_Application(
19  
-            'testing',
  19
+            'integration_testing',
20 20
             ONTOWIKI_ROOT . 'application/config/application.ini'
21 21
         );
22 22
 
24  ...n/tests/unit/controller/ServiceControllerTest.php → .../integration/controller/ServiceControllerTest.php
@@ -40,23 +40,13 @@
40 40
  * @author     Philipp Frischmuth <pfrischmuth@googlemail.com>
41 41
  * @author     Konrad Abicht <k.abicht@googlemail.com>
42 42
  */
43  
-class ServiceControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
  43
+class ServiceControllerTest extends OntoWiki_Test_ControllerTestCase
44 44
 {
45 45
     public function setUp()
46 46
     {
47  
-        $this->bootstrap = new Zend_Application(
48  
-            'testing',
49  
-            ONTOWIKI_ROOT . 'application/config/application.ini'
50  
-        );
51  
-        
52  
-        parent::setUp();
  47
+        $this->setUpIntegrationTest();
53 48
     }
54  
-    
55  
-    public function tearDown()
56  
-    {
57  
-        parent::tearDown();
58  
-    }
59  
-    
  49
+
60 50
     // ------------------------------------------------------------------------
61 51
     // Auth Action
62 52
     // ------------------------------------------------------------------------
@@ -212,7 +202,7 @@ public function sparqlNoParameter()
212 202
      * @test
213 203
      */
214 204
     public function sparqlNoAuthWithInvalidQuery()
215  
-    {        
  205
+    {
216 206
         // Send invalid query
217 207
         $this->request->setMethod('POST')
218 208
                       ->setPost(
@@ -220,10 +210,12 @@ public function sparqlNoAuthWithInvalidQuery()
220 210
                       );
221 211
         
222 212
         $this->dispatch('/service/sparql');
223  
-                
  213
+
  214
+        $code = $this->_response->getHttpResponseCode();
  215
+
224 216
         $this->assertController('service');
225 217
         $this->assertAction('sparql');
226  
-        $this->assertResponseCode(400);
  218
+        $this->assertResponseCode(400, "$code returned instead");
227 219
     }
228 220
     
229 221
     // ------------------------------------------------------------------------
18  application/tests/unit/controller/IndexControllerTest.php
@@ -39,25 +39,13 @@
39 39
  * @author     Norman Heino <norman.heino@gmail.com>
40 40
  * @author     Philipp Frischmuth <pfrischmuth@googlemail.com>
41 41
  */
42  
-class IndexControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
  42
+class IndexControllerTest extends OntoWiki_Test_ControllerTestCase
43 43
 {    
44 44
     public function setUp()
45 45
     {
46  
-        //error_reporting(E_ALL ^ E_WARNING);
47  
-        
48  
-        $this->bootstrap = new Zend_Application(
49  
-            'testing',
50  
-            ONTOWIKI_ROOT . 'application/config/application.ini'
51  
-        );
52  
-        
53  
-        parent::setUp();
  46
+        $this->setUpUnitTest();
54 47
     }
55  
-    
56  
-    public function tearDown()
57  
-    {
58  
-        parent::tearDown();
59  
-    }
60  
-    
  48
+
61 49
     public function testNoControllerAndActionDefaultToNewsAction()
62 50
     {
63 51
         $this->dispatch('/');
15  application/tests/unit/controller/ResourceControllerTest.php
@@ -39,22 +39,11 @@
39 39
  * @license    http://opensource.org/licenses/gpl-2.0.php GNU General Public License, version 2 (GPLv2)
40 40
  * @author     Jonas Brekle <jonas.brekle@gmail.com>
41 41
  */
42  
-class ResourceControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
  42
+class ResourceControllerTest extends OntoWiki_Test_ControllerTestCase
43 43
 {
44 44
     public function setUp()
45 45
     {
46  
-        $this->bootstrap = new Zend_Application(
47  
-            'testing',
48  
-            ONTOWIKI_ROOT . 'application/config/application.ini'
49  
-        );
50  
-        Zend_Controller_Action_HelperBroker::addHelper(new OntoWiki_Controller_ActionHelper_List());
51  
-
52  
-        parent::setUp();
53  
-    }
54  
-
55  
-    public function tearDown()
56  
-    {
57  
-        parent::tearDown();
  46
+        $this->setUpUnitTest();
58 47
     }
59 48
 
60 49
     public function testDummyTestUnlessNoWorkingActualTestExists()
75  extensions/datagathering/tests/DatagatheringControllerTest.php
... ...
@@ -1,27 +1,12 @@
1 1
 <?php
2 2
 
3  
-class DatagatheringControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
  3
+class DatagatheringControllerTest extends OntoWiki_Test_ControllerTestCase
4 4
 {
5  
-    protected $_testAc = null;
6  
-    protected $_testAdapter = null;
7  
-
8 5
     public function setUp()
9 6
     {
10  
-        $this->bootstrap = new Zend_Application(
11  
-            'default',
12  
-            ONTOWIKI_ROOT . 'application/config/application.ini'
13  
-        );
14  
-
15  
-        parent::setUp();
  7
+        $this->_extensionName = 'datagathering';
16 8
 
17  
-        $this->_testAc = new Erfurt_Ac_Test();
18  
-        Erfurt_App::getInstance()->setAc($this->_testAc);
19  
-
20  
-        $this->_testAdapter = new Erfurt_Store_Adapter_Test();
21  
-        Erfurt_App::getInstance()->setStore(new Erfurt_Store(
22  
-            array('adapterInstance' => $this->_testAdapter),
23  
-            'Test'
24  
-        ));
  9
+        $this->setUpExtensionUnitTest();
25 10
     }
26 11
 
27 12
     public function testImportActionRequestTypeNotGetBadRequest()
@@ -58,9 +43,9 @@ public function testImportActionInvalidWrapperParamBadRequest()
58 43
 
59 44
     public function testImportActionModelNotEditableForbidden()
60 45
     {
61  
-        $this->_testAdapter->createModel('http://example.org/testModel1');
62  
-        $this->_testAc->setUserModelRight('http://example.org/testModel1', 'view', 'grant');
63  
-        $this->_testAc->setUserModelRight('http://example.org/testModel1', 'edit', 'deny');
  46
+        $this->_storeAdapter->createModel('http://example.org/testModel1');
  47
+        $this->_ac->setUserModelRight('http://example.org/testModel1', 'view', 'grant');
  48
+        $this->_ac->setUserModelRight('http://example.org/testModel1', 'edit', 'deny');
64 49
 
65 50
         $this->request->setQuery(array(
66 51
             'uri' => 'http://example.org/testResource1',
@@ -76,9 +61,9 @@ public function testImportActionModelNotEditableForbidden()
76 61
 
77 62
     public function testImportActionWrapperResultFalse()
78 63
     {
79  
-        $this->_testAdapter->createModel('http://example.org/testModel1');
80  
-        $this->_testAc->setUserModelRight('http://example.org/testModel1', 'view', 'grant');
81  
-        $this->_testAc->setUserModelRight('http://example.org/testModel1', 'edit', 'grant');
  64
+        $this->_storeAdapter->createModel('http://example.org/testModel1');
  65
+        $this->_ac->setUserModelRight('http://example.org/testModel1', 'view', 'grant');
  66
+        $this->_ac->setUserModelRight('http://example.org/testModel1', 'edit', 'grant');
82 67
 
83 68
         $this->request->setQuery(array(
84 69
             'uri'     => 'http://example.org/testResource1',
@@ -102,9 +87,9 @@ public function testImportActionWrapperResultFalse()
102 87
 
103 88
     public function testImportActionWrapperResultEmptyArray()
104 89
     {
105  
-        $this->_testAdapter->createModel('http://example.org/testModel1');
106  
-        $this->_testAc->setUserModelRight('http://example.org/testModel1', 'view', 'grant');
107  
-        $this->_testAc->setUserModelRight('http://example.org/testModel1', 'edit', 'grant');
  90
+        $this->_storeAdapter->createModel('http://example.org/testModel1');
  91
+        $this->_ac->setUserModelRight('http://example.org/testModel1', 'view', 'grant');
  92
+        $this->_ac->setUserModelRight('http://example.org/testModel1', 'edit', 'grant');
108 93
 
109 94
         Erfurt_Wrapper_Test::$runResult = array();
110 95
 
@@ -130,9 +115,9 @@ public function testImportActionWrapperResultEmptyArray()
130 115
 
131 116
     public function testImportActionWrapperResultArrayNoAdd()
132 117
     {
133  
-        $this->_testAdapter->createModel('http://example.org/testModel1');
134  
-        $this->_testAc->setUserModelRight('http://example.org/testModel1', 'view', 'grant');
135  
-        $this->_testAc->setUserModelRight('http://example.org/testModel1', 'edit', 'grant');
  118
+        $this->_storeAdapter->createModel('http://example.org/testModel1');
  119
+        $this->_ac->setUserModelRight('http://example.org/testModel1', 'view', 'grant');
  120
+        $this->_ac->setUserModelRight('http://example.org/testModel1', 'edit', 'grant');
136 121
 
137 122
         Erfurt_Wrapper_Test::$runResult = array('status_codes' => array());
138 123
 
@@ -160,9 +145,9 @@ public function testImportActionWrapperResultArrayWithAddButNothingAdded()
160 145
     {
161 146
         Erfurt_App::getInstance()->getVersioning()->enableVersioning(false);
162 147
 
163  
-        $this->_testAdapter->createModel('http://example.org/testModel1');
164  
-        $this->_testAc->setUserModelRight('http://example.org/testModel1', 'view', 'grant');
165  
-        $this->_testAc->setUserModelRight('http://example.org/testModel1', 'edit', 'grant');
  148
+        $this->_storeAdapter->createModel('http://example.org/testModel1');
  149
+        $this->_ac->setUserModelRight('http://example.org/testModel1', 'view', 'grant');
  150
+        $this->_ac->setUserModelRight('http://example.org/testModel1', 'edit', 'grant');
166 151
 
167 152
         Erfurt_Wrapper_Test::$runResult = array(
168 153
             'status_codes' => array(Erfurt_Wrapper::RESULT_HAS_ADD),
@@ -193,12 +178,12 @@ public function testImportActionWrapperResultArrayWithAdd()
193 178
     {
194 179
         Erfurt_App::getInstance()->getVersioning()->enableVersioning(false);
195 180
 
196  
-        $this->_testAdapter->createModel('http://example.org/testModel1');
197  
-        $this->_testAc->setUserModelRight('http://example.org/testModel1', 'view', 'grant');
198  
-        $this->_testAc->setUserModelRight('http://example.org/testModel1', 'edit', 'grant');
  181
+        $this->_storeAdapter->createModel('http://example.org/testModel1');
  182
+        $this->_ac->setUserModelRight('http://example.org/testModel1', 'view', 'grant');
  183
+        $this->_ac->setUserModelRight('http://example.org/testModel1', 'edit', 'grant');
199 184
 
200  
-        $this->_testAdapter->addCountResult(0);
201  
-        $this->_testAdapter->addCountResult(2);
  185
+        $this->_storeAdapter->addCountResult(0);
  186
+        $this->_storeAdapter->addCountResult(2);
202 187
 
203 188
         $add = array(
204 189
             'http://example.org/testResource1' => array(
@@ -238,19 +223,19 @@ public function testImportActionWrapperResultArrayWithAdd()
238 223
         $this->assertArrayHasKey('message', $result);
239 224
         $this->assertNotEmpty($result['message']);
240 225
 
241  
-        $this->assertEquals($add, $this->_testAdapter->getStatementsForGraph('http://example.org/testModel1'));
  226
+        $this->assertEquals($add, $this->_storeAdapter->getStatementsForGraph('http://example.org/testModel1'));
242 227
     }
243 228
 
244 229
     public function testImportActionWrapperResultArrayWithAddMatchingPreset()
245 230
     {
246 231
         Erfurt_App::getInstance()->getVersioning()->enableVersioning(false);
247 232
 
248  
-        $this->_testAdapter->createModel('http://example.org/testModel1');
249  
-        $this->_testAc->setUserModelRight('http://example.org/testModel1', 'view', 'grant');
250  
-        $this->_testAc->setUserModelRight('http://example.org/testModel1', 'edit', 'grant');
  233
+        $this->_storeAdapter->createModel('http://example.org/testModel1');
  234
+        $this->_ac->setUserModelRight('http://example.org/testModel1', 'view', 'grant');
  235
+        $this->_ac->setUserModelRight('http://example.org/testModel1', 'edit', 'grant');
251 236
 
252  
-        $this->_testAdapter->addCountResult(0);
253  
-        $this->_testAdapter->addCountResult(2);
  237
+        $this->_storeAdapter->addCountResult(0);
  238
+        $this->_storeAdapter->addCountResult(2);
254 239
 
255 240
         $add = array(
256 241
             'http://dbpedia.org/resource/Leipzig' => array(
@@ -290,6 +275,6 @@ public function testImportActionWrapperResultArrayWithAddMatchingPreset()
290 275
         $this->assertArrayHasKey('message', $result);
291 276
         $this->assertNotEmpty($result['message']);
292 277
 
293  
-        $this->assertEquals(array(), $this->_testAdapter->getStatementsForGraph('http://example.org/testModel1'));
  278
+        $this->assertEquals(array(), $this->_storeAdapter->getStatementsForGraph('http://example.org/testModel1'));
294 279
     }
295 280
 }
20  extensions/source/tests/SourceControllerTest.php
... ...
@@ -1,25 +1,25 @@
1 1
 <?php
2 2
 
3  
-class SourceControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
  3
+class SourceControllerTest extends OntoWiki_Test_ControllerTestCase
4 4
 {
5 5
     public function setUp()
6 6
     {
7  
-        $this->bootstrap = new Zend_Application(
8  
-            'testing',
9  
-            ONTOWIKI_ROOT . 'application/config/application.ini'
10  
-        );
11  
-        parent::setUp();
  7
+        $this->_extensionName = 'source';
  8
+
  9
+        $this->setUpExtensionUnitTest();
12 10
     }
13 11
 
14 12
     public function testDispatching()
15 13
     {
16  
-        $this->dispatch('/source/edit');
17  
-        $this->request->setParam('m', 'http://localhost/OntoWiki/Config/');
  14
+        $this->_storeAdapter->createModel('http://localhost/OntoWiki/Config/');
  15
+        $this->_ac->setUserModelRight('http://localhost/OntoWiki/Config/', 'view', 'grant');
  16
+        $this->_ac->setUserModelRight('http://localhost/OntoWiki/Config/', 'edit', 'grant');
18 17
 
19  
-        $r = $this->getResponse();
20  
-        // var_dump($r->getBody());
  18
+        $this->request->setParam('m', 'http://localhost/OntoWiki/Config/');
  19
+        $this->dispatch('/source/edit');
21 20
 
22 21
         $this->assertController('source');
23 22
         $this->assertAction('edit');
  23
+        @$this->assertResponseCode(200);
24 24
     }
25 25
 }
2  libraries/Erfurt
... ...
@@ -1 +1 @@
1  
-Subproject commit 199302dd9345257bc304d53c6b4a295c22cc41ac
  1
+Subproject commit da0e6150d228a7872b65fb7ff4c5c5a08708aa63

Git Notes

jenkins

{
  "built_on": "master",
  "duration": 56.937,
  "full_display_name": "OntoWiki #29",
  "id": "2012-09-10_15-09-47",
  "number": 29,
  "result": "SUCCESS",
  "status_message": "?",
  "time": "2012-09-10 15:09:47 +0200",
  "url": "job/OntoWiki/29/"
}

0 notes on commit 5a2a632

Please sign in to comment.
Something went wrong with that request. Please try again.