From d4f1df0fcbfd878a035f48ee6633ef4471bd2497 Mon Sep 17 00:00:00 2001 From: Philipp Frischmuth Date: Wed, 29 Jun 2016 16:56:45 +0200 Subject: [PATCH 1/4] Fix some bugs in order to fix tests - Fix old style count for ZendDb backends - Fix Virtuoso ResultRenderer XmlTemplate to use UTF-8 encoding when encoding not set - Fix import closure to respect useAc parameter - Fix AC check that in some cases always returned true --- library/Erfurt/Ac/Default.php | 5 ++++- library/Erfurt/Sparql/SimpleQuery.php | 19 +++++++++++++++++++ library/Erfurt/Store.php | 5 ++--- .../Virtuoso/ResultConverter/XmlTemplate.pxml | 11 ++++++----- .../Erfurt/StoreIntegrationTest.php | 4 ++-- 5 files changed, 33 insertions(+), 11 deletions(-) diff --git a/library/Erfurt/Ac/Default.php b/library/Erfurt/Ac/Default.php index 402ad68d..2ba550e8 100644 --- a/library/Erfurt/Ac/Default.php +++ b/library/Erfurt/Ac/Default.php @@ -279,8 +279,11 @@ public function isModelAllowed($type, $modelUri) $modelUri = (string)$modelUri; $result = $this->areModelsAllowed($type, array($modelUri)); if (isset($result[$modelUri])) { - return $result[$modelUri]; + if ($result[$modelUri] === true) { + return true; + } } + return false; } diff --git a/library/Erfurt/Sparql/SimpleQuery.php b/library/Erfurt/Sparql/SimpleQuery.php index 4075f112..9a65a426 100644 --- a/library/Erfurt/Sparql/SimpleQuery.php +++ b/library/Erfurt/Sparql/SimpleQuery.php @@ -32,6 +32,9 @@ class Erfurt_Sparql_SimpleQuery /** @var boolean */ protected $_ask = false; + /** @var boolean */ + protected $_oldCount = false; + /** @var array */ protected $_from = array(); @@ -60,6 +63,8 @@ public function __toString() if ($this->_ask) { $queryString .= 'ASK' . PHP_EOL; + } else if ($this->_oldCount) { + $queryString .= 'COUNT' . PHP_EOL; } else { $queryString .= $this->_selectClause . PHP_EOL; } @@ -120,6 +125,7 @@ public static function initWithString($queryString) 'prefix' => '/((PREFIX\s+[^:\s]+:\s+<[^\s]*>\s*)+)/si', 'base' => '/BASE\s+<(.+?)>/i', 'ask' => '/(ASK)/si', + 'old_count' => '/(COUNT\s+(FROM|WHERE))/si', 'select_clause' => '/((SELECT\s+)(DISTINCT\s+)?)(\*|((COUNT\s*\((\?\w*|\*)\)\s+(as\s+(\?\w+\s+))?)|(\?\w+\s+))*)/si', 'from' => '/FROM\s+<(.+?)>/i', 'from_named' => '/FROM\s+NAMED\s+<(.+?)>/i', @@ -152,6 +158,10 @@ public static function initWithString($queryString) $queryObject->setAsk(true); } + if (isset($parts['old_count'][0][0])) { + $queryObject->setOldCount(true); + } + if (isset($parts['select_clause'][0][0])) { $queryObject->setSelectClause($parts['select_clause'][0][0]); } @@ -320,6 +330,15 @@ public function setAsk($ask = true) return $this; } + public function setOldCount($oldCount = true) { + + if ($oldCount === true | strtolower($oldCount) == 'count') { + $this->_oldCount = true; + } else { + $this->_oldCount = false; + } + } + public function setSelectClause($selectClauseString) { $this->_selectClause = $selectClauseString; diff --git a/library/Erfurt/Store.php b/library/Erfurt/Store.php index 2144ed58..47c6d851 100644 --- a/library/Erfurt/Store.php +++ b/library/Erfurt/Store.php @@ -979,7 +979,7 @@ public function getImportsClosure($modelIri, $withHiddenImports = true, $useAC = * * @param string $modelIri */ - private function _getImportsClosure($modelIri, $withHiddenImports = true) + private function _getImportsClosure($modelIri, $withHiddenImports = true, $useAC = true) { $currentLevel = $this->_backendAdapter->getImportsClosure($modelIri); if ($currentLevel == array($modelIri)) { @@ -1002,7 +1002,7 @@ private function _getImportsClosure($modelIri, $withHiddenImports = true) foreach ($graphConfig[$importsUri] as $valueArray) { $currentLevel = array_merge( $currentLevel, - $this->getImportsClosure($valueArray['value'], $withHiddenImports) + $this->getImportsClosure($valueArray['value'], $withHiddenImports, $useAC) ); } } @@ -2133,7 +2133,6 @@ public function getResourceDescription( return $fetchedDesc; } - // ------------------------------------------------------------------------ // --- Protected Methods -------------------------------------------------- // ------------------------------------------------------------------------ diff --git a/library/Erfurt/Store/Adapter/Virtuoso/ResultConverter/XmlTemplate.pxml b/library/Erfurt/Store/Adapter/Virtuoso/ResultConverter/XmlTemplate.pxml index e3e26c32..d3e929ea 100644 --- a/library/Erfurt/Store/Adapter/Virtuoso/ResultConverter/XmlTemplate.pxml +++ b/library/Erfurt/Store/Adapter/Virtuoso/ResultConverter/XmlTemplate.pxml @@ -2,16 +2,17 @@ diff --git a/tests/integration/Erfurt/StoreIntegrationTest.php b/tests/integration/Erfurt/StoreIntegrationTest.php index 9cc7320b..3cef31b0 100644 --- a/tests/integration/Erfurt/StoreIntegrationTest.php +++ b/tests/integration/Erfurt/StoreIntegrationTest.php @@ -159,12 +159,12 @@ public function testSparqlQueryWithCountAndFromIssue174() $query = 'COUNT FROM WHERE { - ?s ?p ?o . + ?p ?o . }'; $simpleQuery = Erfurt_Sparql_SimpleQuery::initWithString($query); $result = $store->sparqlQuery($simpleQuery); - $this->assertEquals(208, $result); + $this->assertEquals(4, $result); } public function testCountWhereMatchesWithNonExistingModel() From 829918e4e0c508b90536a6af6c4787b16c7fcde9 Mon Sep 17 00:00:00 2001 From: Philipp Frischmuth Date: Wed, 29 Jun 2016 16:57:07 +0200 Subject: [PATCH 2/4] Fix invalid PHP file --- .../Standards/Erfurt/Sniffs/Commenting/FileCommentSniff.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/CodeSniffer/Standards/Erfurt/Sniffs/Commenting/FileCommentSniff.php b/tests/CodeSniffer/Standards/Erfurt/Sniffs/Commenting/FileCommentSniff.php index 1c1d3b93..6b38dd67 100644 --- a/tests/CodeSniffer/Standards/Erfurt/Sniffs/Commenting/FileCommentSniff.php +++ b/tests/CodeSniffer/Standards/Erfurt/Sniffs/Commenting/FileCommentSniff.php @@ -30,8 +30,7 @@ class Erfurt_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff 2 => " * This file is part of the {@link http://erfurt-framework.org Erfurt} project.\n", 3 => " *\n", 4 => "", - 5 => " * @license http://opensource.org/licenses/gpl-license.php " - . "GNU General Public License (GPL)\n", + 5 => " * @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)\n", 6 => " */", ); From 7508ed6bb4ff7e42cbe0b945b2707a309bd5a4d5 Mon Sep 17 00:00:00 2001 From: Philipp Frischmuth Date: Wed, 29 Jun 2016 16:58:52 +0200 Subject: [PATCH 3/4] Cleanup phpunit config - Remove duplicated test suite - Remove logging settings in order to speed up phpunit runs (log settings are overwritten in ant builds) --- phpunit.xml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 428cae79..9586ec29 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -10,18 +10,9 @@ tests/unit - + tests/integration - - tests/integration - - - - - - - ./library/Erfurt From c2204d2e152301c9fec5b4b105e0fe4adb662f0f Mon Sep 17 00:00:00 2001 From: Philipp Frischmuth Date: Wed, 29 Jun 2016 17:01:11 +0200 Subject: [PATCH 4/4] Fix ant builds in order to fix owdev jenkins builds - Require PHP 5.4.0 - Adjust settings for test targets in Makefile - Add some dev requirements used by ant builds - Remove a now unused config files - Fix settings in build.xml to work with dependencies under vendor folder - Disable phpdoc target, since doc-creator is not working --- Makefile | 25 ++++++++------- build.xml | 84 +++++++++++++++++++++++++++---------------------- build/phpcs.xml | 6 ---- build/phpmd.xml | 6 ++-- composer.json | 11 +++++-- 5 files changed, 72 insertions(+), 60 deletions(-) delete mode 100644 build/phpcs.xml diff --git a/Makefile b/Makefile index 36a7044c..449c4243 100644 --- a/Makefile +++ b/Makefile @@ -90,20 +90,23 @@ endif # coding standard # test stuff -test-directories: - rm -rf tests/cache tests/unit/cache tests/integration/cache - mkdir tests/cache - mkdir tests/unit/cache - mkdir tests/integration/cache - -test-unit: test-directories +test-unit: directories $(PHPUNIT) --testsuite "Erfurt Unit Tests" -test-integration-virtuoso: test-directories - EF_STORE_ADAPTER=virtuoso $(PHPUNIT) --testsuite "Erfurt Virtuoso Integration Tests" +test-unit-cc: directories + $(PHPUNIT) --testsuite "Erfurt Unit Tests" --coverage-clover ./build/logs/clover.xml --coverage-html ./build/coverage --log-junit ./build/logs/junit.xml + +test-integration-virtuoso: directories + EF_STORE_ADAPTER=virtuoso $(PHPUNIT) --testsuite "Erfurt Integration Tests" + +test-integration-virtuoso-cc: directories + EF_STORE_ADAPTER=virtuoso $(PHPUNIT) --testsuite "Erfurt Integration Tests" --coverage-html ./build/coverage-virtuoso + +test-integration-mysql: directories + EF_STORE_ADAPTER=zenddb $(PHPUNIT) --testsuite "Erfurt Integration Tests" -test-integration-mysql: test-directories - EF_STORE_ADAPTER=zenddb $(PHPUNIT) --testsuite "Erfurt Virtuoso Integration Tests" +test-integration-mysql-cc: directories + EF_STORE_ADAPTER=zenddb $(PHPUNIT) --testsuite "Erfurt Integration Tests" --coverage-html ./build/coverage-mysql test: make test-unit diff --git a/build.xml b/build.xml index b98a197c..8f2509e3 100644 --- a/build.xml +++ b/build.xml @@ -2,9 +2,9 @@ - - - + + + @@ -12,7 +12,8 @@ - + + @@ -21,7 +22,8 @@ - + + @@ -38,7 +40,7 @@ - + @@ -46,7 +48,7 @@ - + @@ -54,46 +56,26 @@ - - - - - - - - - - - - - - - - - - - - + + - + - + - + @@ -101,8 +83,7 @@ - - + @@ -111,20 +92,27 @@ - + - + + + - + + + + + + - + @@ -133,4 +121,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/build/phpcs.xml b/build/phpcs.xml deleted file mode 100644 index 78d938f4..00000000 --- a/build/phpcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - -OntoWiki rule set for PHP_CodeSniffer - - \ No newline at end of file diff --git a/build/phpmd.xml b/build/phpmd.xml index b78c8613..3c91c3c0 100644 --- a/build/phpmd.xml +++ b/build/phpmd.xml @@ -1,8 +1,8 @@ - diff --git a/composer.json b/composer.json index ae8f99b1..0cb67595 100644 --- a/composer.json +++ b/composer.json @@ -11,13 +11,20 @@ } ], "require": { - "php": ">=5.3.3", + "php": ">=5.4.0", "semsol/arc2": "*", "zendframework/zendframework1": "1.*" }, "require-dev": { "phpunit/phpunit": "4.5.*", - "squizlabs/php_codesniffer": "dev-master" + "squizlabs/php_codesniffer": "dev-master", + "ceus-media/common": "dev-master", + "ceus-media/doc-creator": "dev-master", + "zerkalica/php-code-browser": "dev-master", + "sebastian/phpcpd": "2.0.*", + "pdepend/pdepend": "2.2.*", + "phploc/phploc": "2.1.*", + "phpmd/phpmd": "2.4.*" }, "autoload": { "classmap": [