From b7b6a3bc27afeab2f5e3c1fbc2ef1a96be5be945 Mon Sep 17 00:00:00 2001 From: Andrei Shapiro Date: Tue, 30 May 2023 08:21:25 +0000 Subject: [PATCH] chore: apply PSR-12 manual fixes --- common/class.Logger.php | 5 +- common/log/class.Item.php | 12 +- common/user/auth/class.Service.php | 7 +- common/user/class.User.php | 6 +- core/GenerisRdf.php | 1 + core/kernel/classes/class.Class.php | 23 +- core/kernel/classes/class.ClassFactory.php | 9 +- core/kernel/classes/class.ClassIterator.php | 9 +- .../classes/class.ContainerCollection.php | 6 +- core/kernel/classes/class.DbWrapper.php | 8 +- .../class.MultiplePropertyValuesException.php | 5 +- core/kernel/classes/class.Resource.php | 28 ++- .../classes/class.ResourceFormatter.php | 4 +- .../kernel/classes/class.ResourceIterator.php | 3 +- core/kernel/impl/class.ApiModelOO.php | 4 +- .../persistence/interface.ClassInterface.php | 14 +- .../interface.ResourceInterface.php | 39 +++- core/kernel/persistence/newsql/NewSqlRdf.php | 3 +- .../persistence/smoothsql/class.Class.php | 96 ++++++-- .../persistence/smoothsql/class.Property.php | 13 +- .../persistence/smoothsql/class.Resource.php | 79 +++++-- .../smoothsql/class.SmoothModel.php | 12 +- .../persistence/smoothsql/class.SmoothRdf.php | 10 +- .../persistence/smoothsql/class.Utils.php | 41 +++- .../smoothsql/search/ComplexSearchService.php | 14 +- .../smoothsql/search/QueryJoiner.php | 209 ++++++++++-------- .../kernel/persistence/wrapper/RdfWrapper.php | 13 +- core/kernel/rules/class.Expression.php | 21 +- core/kernel/rules/class.ExpressionFactory.php | 20 +- core/kernel/rules/class.Operation.php | 10 +- core/kernel/rules/class.OperationFactory.php | 10 +- core/kernel/rules/class.Rule.php | 8 +- core/kernel/rules/class.Term.php | 22 +- core/kernel/rules/class.TermFactory.php | 8 +- core/kernel/uri/Bin2HexUriProvider.php | 3 +- core/kernel/uri/MicrotimeRandUriProvider.php | 12 +- .../uri/class.DatabaseSerialUriProvider.php | 12 +- core/kernel/users/class.AuthAdapter.php | 8 +- core/kernel/users/class.Cache.php | 3 +- core/kernel/users/class.Service.php | 44 ++-- .../users/interface.RolesManagement.php | 8 +- core/user/AuthAdapter.php | 16 +- test/GenerisPhpUnitTestRunner.php | 4 +- test/OntologyMockTrait.php | 4 +- test/integration/ClassTest.php | 56 ++++- test/integration/ComplexSearchTest.php | 4 +- test/integration/CreateInstanceTest.php | 29 ++- test/integration/DbWrapperTest.php | 15 +- test/integration/RdfExportTest.php | 5 +- test/integration/ResourceTest.php | 45 +++- test/integration/SqlInjectionTest.php | 5 +- test/integration/UserServiceTest.php | 18 +- .../filesystem/DirectoryFilesystemTest.php | 4 +- .../FileSerializerMigrationHelperTest.php | 8 +- test/integration/helpers/FileTest.php | 8 +- .../model/persistence/file/FileModelTest.php | 5 +- .../smoothsql/SmoothsqlUtilsTest.php | 95 ++++++-- test/integration/mutex/LockServiceTest.php | 30 ++- .../rules/ExpressionFactoryTest.php | 16 +- test/integration/rules/ExpressionTest.php | 180 ++++++++++++--- test/integration/rules/TermFactoryTest.php | 5 +- test/integration/rules/TermTest.php | 5 +- test/samples/manifests/complexManifest.php | 19 +- test/unit/ConfigurationTest.php | 16 +- test/unit/FileHelperTest.php | 11 +- test/unit/ManifestTest.php | 8 +- test/unit/UtilsTest.php | 19 +- .../configuration/ComponentFactoryTest.php | 25 ++- .../configuration/FileSystemComponentTest.php | 9 +- .../AdvKeyValuePersistenceTest.php | 25 ++- test/unit/helpers/FileTest.php | 21 +- .../model/data/permission/FreeAccessTest.php | 10 +- .../data/permission/IntersectionTest.php | 25 ++- .../persistence/newsql/NewSqlRdfTest.php | 3 +- .../persistence/smoothsql/SmoothRdfTest.php | 6 +- test/unit/oatbox/mutex/LockServiceTest.php | 39 +++- .../service/EnvironmentVariableTest.php | 5 +- 77 files changed, 1265 insertions(+), 395 deletions(-) diff --git a/common/class.Logger.php b/common/class.Logger.php index 682bd4828..0560c0f79 100644 --- a/common/class.Logger.php +++ b/common/class.Logger.php @@ -466,8 +466,9 @@ public function handlePHPShutdown() if ($error !== null && ($error['type'] & (E_COMPILE_ERROR | E_ERROR | E_PARSE | E_CORE_ERROR)) !== 0) { $msg = (isset($error['file'], $error['line'])) - ? 'php error(' . $error['type'] . ') in ' . $error['file'] . '@' . $error['line'] . ': ' . $error['message'] - : 'php error(' . $error['type'] . '): ' . $error['message']; + ? 'php error(' . $error['type'] . ') in ' . $error['file'] . '@' . $error['line'] . ': ' + . $error['message'] + : 'php error(' . $error['type'] . '): ' . $error['message']; self::singleton()->log(self::FATAL_LEVEL, $msg, ['PHPERROR']); } } diff --git a/common/log/class.Item.php b/common/log/class.Item.php index 82e6b2932..09a1e6a4e 100644 --- a/common/log/class.Item.php +++ b/common/log/class.Item.php @@ -115,8 +115,16 @@ class common_log_Item * @param int errorLine * @return mixed */ - public function __construct($description, $severity, $datetime, $backtrace = [], $tags = [], $request = "", $errorFile = '', $errorLine = 0) - { + public function __construct( + $description, + $severity, + $datetime, + $backtrace = [], + $tags = [], + $request = "", + $errorFile = '', + $errorLine = 0 + ) { if (!is_string($description)) { throw new InvalidArgumentException("The description must be a string, " . gettype($description) . " given"); } diff --git a/common/user/auth/class.Service.php b/common/user/auth/class.Service.php index 5f9ec8991..da973561e 100755 --- a/common/user/auth/class.Service.php +++ b/common/user/auth/class.Service.php @@ -67,9 +67,10 @@ private function __construct() * * @access public * @author Jerome Bogaerts, - * @param string login The login of the user. - * @param string password the md5 hash of the password. - * @param allowedRoles A Role or an array of Roles that are allowed to be logged in. If the user has a Role that matches one or more Roles in this array, the login request will be accepted. + * @param string $login The login of the user. + * @param string $password the md5 hash of the password. + * @param $allowedRoles - A Role or an array of Roles that are allowed to be logged in. If the user has a Role that + * matches one or more Roles in this array, the login request will be accepted. * @return boolean */ public function login(common_user_auth_Adapter $adapter, $allowedRoles = []) diff --git a/common/user/class.User.php b/common/user/class.User.php index a21c61db1..11607e9b2 100755 --- a/common/user/class.User.php +++ b/common/user/class.User.php @@ -58,7 +58,11 @@ public function getRoles() // We use a Depth First Search approach to flatten the Roles Graph. foreach ($this->getPropertyValues(GenerisRdf::PROPERTY_USER_ROLES) as $roleUri) { $returnValue[] = $roleUri; - foreach (core_kernel_users_Service::singleton()->getIncludedRoles(new core_kernel_classes_Resource($roleUri)) as $role) { + $includedRoles = core_kernel_users_Service::singleton()->getIncludedRoles( + new core_kernel_classes_Resource($roleUri) + ); + + foreach ($includedRoles as $role) { $returnValue[] = $role->getUri(); } } diff --git a/core/GenerisRdf.php b/core/GenerisRdf.php index 80c21a1e9..c222b9fa1 100644 --- a/core/GenerisRdf.php +++ b/core/GenerisRdf.php @@ -17,6 +17,7 @@ * * Copyright (c) 2017 (original work) Open Assessment Technologies SA; * + * phpcs:disable Generic.Files.LineLength */ namespace oat\generis\model; diff --git a/core/kernel/classes/class.Class.php b/core/kernel/classes/class.Class.php index 36a9b3c8b..aa6bd9f49 100644 --- a/core/kernel/classes/class.Class.php +++ b/core/kernel/classes/class.Class.php @@ -357,9 +357,17 @@ public function countInstances($propertyFilters = [], $options = []) * @param array options * @return \core_kernel_classes_Resource[] */ - public function getInstancesPropertyValues(core_kernel_classes_Property $property, $propertyFilters = [], $options = []) - { - return (array) $this->getImplementation()->getInstancesPropertyValues($this, $property, $propertyFilters, $options); + public function getInstancesPropertyValues( + core_kernel_classes_Property $property, + $propertyFilters = [], + $options = [] + ) { + return (array) $this->getImplementation()->getInstancesPropertyValues( + $this, + $property, + $propertyFilters, + $options + ); } /** @@ -394,7 +402,9 @@ public function createInstanceWithProperties($properties) $additionalTypes = []; if (isset($properties[OntologyRdf::RDF_TYPE])) { - $types = is_array($properties[OntologyRdf::RDF_TYPE]) ? $properties[OntologyRdf::RDF_TYPE] : [$properties[OntologyRdf::RDF_TYPE]]; + $types = is_array($properties[OntologyRdf::RDF_TYPE]) + ? $properties[OntologyRdf::RDF_TYPE] + : [$properties[OntologyRdf::RDF_TYPE]]; foreach ($types as $type) { $uri = is_object($type) ? $type->getUri() : $type; if ($uri != $this->getUri()) { @@ -418,8 +428,9 @@ public function createInstanceWithProperties($properties) * * @access public * @author Jerome Bogaerts, - * @param array resources An array of core_kernel_classes_Resource or URIs. - * @param boolean deleteReference If set to true, references about the resources will also be deleted from the database. + * @param array $resources An array of core_kernel_classes_Resource or URIs. + * @param boolean $deleteReference If set to true, references about the resources will also be deleted from the + * database. * @return boolean */ public function deleteInstances($resources, $deleteReference = false) diff --git a/core/kernel/classes/class.ClassFactory.php b/core/kernel/classes/class.ClassFactory.php index 38dc8014c..a34f57dff 100644 --- a/core/kernel/classes/class.ClassFactory.php +++ b/core/kernel/classes/class.ClassFactory.php @@ -95,8 +95,13 @@ public static function createInstance(core_kernel_classes_Class $clazz, $label = * @param string uri * @return core_kernel_classes_Property */ - public static function createProperty(core_kernel_classes_Class $clazz, $label = '', $comment = '', $isLgDependent = false, $uri = '') - { + public static function createProperty( + core_kernel_classes_Class $clazz, + $label = '', + $comment = '', + $isLgDependent = false, + $uri = '' + ) { $returnValue = null; $property = new core_kernel_classes_Class(OntologyRdf::RDF_PROPERTY); $propertyInstance = self::createInstance($property, $label, $comment, $uri); diff --git a/core/kernel/classes/class.ClassIterator.php b/core/kernel/classes/class.ClassIterator.php index 88a54639b..dcff257cf 100644 --- a/core/kernel/classes/class.ClassIterator.php +++ b/core/kernel/classes/class.ClassIterator.php @@ -47,7 +47,9 @@ public function __construct($classes) { $classes = is_array($classes) ? $classes : [$classes]; foreach ($classes as $class) { - $this->todoClasses[] = (is_object($class) && $class instanceof core_kernel_classes_Class) ? $class->getUri() : $class; + $this->todoClasses[] = (is_object($class) && $class instanceof core_kernel_classes_Class) + ? $class->getUri() + : $class; } $this->rewind(); } @@ -92,7 +94,10 @@ public function next() $this->classes[] = $newUri; $class = new \core_kernel_classes_Class($newUri); foreach ($class->getSubClasses(false) as $subClass) { - if (!in_array($subClass->getUri(), $this->classes) && !in_array($subClass->getUri(), $this->todoClasses)) { + if ( + !in_array($subClass->getUri(), $this->classes) + && !in_array($subClass->getUri(), $this->todoClasses) + ) { $this->todoClasses[] = $subClass->getUri(); } } diff --git a/core/kernel/classes/class.ContainerCollection.php b/core/kernel/classes/class.ContainerCollection.php index 6dd6524a6..50a47cac8 100644 --- a/core/kernel/classes/class.ContainerCollection.php +++ b/core/kernel/classes/class.ContainerCollection.php @@ -90,7 +90,11 @@ public function intersect(common_Collection $collection) $returnValue = new core_kernel_classes_ContainerCollection(new common_Object(__METHOD__)); - $returnValue->sequence = array_uintersect($this->sequence, $collection->sequence, 'core_kernel_classes_ContainerComparator::compare'); + $returnValue->sequence = array_uintersect( + $this->sequence, + $collection->sequence, + 'core_kernel_classes_ContainerComparator::compare' + ); return $returnValue; diff --git a/core/kernel/classes/class.DbWrapper.php b/core/kernel/classes/class.DbWrapper.php index 167d948bc..f34ee6072 100644 --- a/core/kernel/classes/class.DbWrapper.php +++ b/core/kernel/classes/class.DbWrapper.php @@ -422,9 +422,11 @@ public function getColumnNotFoundErrorCode() * @abstract * @access public * @author Jerome Bogaerts, - * @param string indexName The name of the index to create. - * @param string tableName A table name - * @param array columns An associative array that represents the columns on which the index applies. The keys of the array are the name of the columns, the values are the length of the data to index in the column. If there is no length limitation, set the value of the array cell to null. + * @param string $indexName The name of the index to create. + * @param string $tableName A table name + * @param array $columns An associative array that represents the columns on which the index applies. The keys of + * the array are the name of the columns, the values are the length of the data to index in + * the column. If there is no length limitation, set the value of the array cell to null. * @return void */ public function createIndex($indexName, $tableName, $columns) diff --git a/core/kernel/classes/class.MultiplePropertyValuesException.php b/core/kernel/classes/class.MultiplePropertyValuesException.php index dee557684..f30a87bef 100644 --- a/core/kernel/classes/class.MultiplePropertyValuesException.php +++ b/core/kernel/classes/class.MultiplePropertyValuesException.php @@ -56,7 +56,10 @@ public function __construct(core_kernel_classes_Resource $resource, core_kernel_ $this->resource = $resource; $this->property = $property; - parent::__construct('Property ( ' . $property->getUri() . ' ) of resource ' . ' ( ' . $resource->getUri() . ' ) has more than one value do not use getUniquePropertyValue but use getPropertyValue instead'); + parent::__construct( + 'Property ( ' . $property->getUri() . ' ) of resource ' . ' ( ' . $resource->getUri() + . ' ) has more than one value do not use getUniquePropertyValue but use getPropertyValue instead' + ); } /** diff --git a/core/kernel/classes/class.Resource.php b/core/kernel/classes/class.Resource.php index 88f9115ca..148e24b25 100644 --- a/core/kernel/classes/class.Resource.php +++ b/core/kernel/classes/class.Resource.php @@ -109,10 +109,15 @@ private function getImplementation() public function __construct($uri, $debug = '') { if (empty($uri)) { - throw new common_exception_Error('cannot construct the resource because the uri cannot be empty, debug: ' . $debug); + throw new common_exception_Error( + 'cannot construct the resource because the uri cannot be empty, debug: ' . $debug + ); } if (!is_string($uri) && !$uri instanceof self) { - throw new common_exception_Error('could not create resource from ' . (is_object($uri) ? get_class($uri) : gettype($uri)) . ' debug: ' . $debug); + throw new common_exception_Error( + 'could not create resource from ' . (is_object($uri) ? get_class($uri) : gettype($uri)) + . ' debug: ' . $debug + ); } $this->uriResource = $uri instanceof self ? $uri->getUri() : $uri; } @@ -126,7 +131,9 @@ public function __construct($uri, $debug = '') */ public function __clone() { - throw new common_exception_DeprecatedApiMethod('Use duplicated instead, because clone resource could not share same uri that original'); + throw new common_exception_DeprecatedApiMethod( + 'Use duplicated instead, because clone resource could not share same uri that original' + ); } public function isCustom(): bool @@ -196,7 +203,8 @@ public function isProperty() * Returns all the types of this resource as core_kernel_classes_Class objects. * * @author Joel Bout - * @return core_kernel_classes_Class[] An associative array where keys are class URIs and values are core_kernel_classes_Class objects. + * @return core_kernel_classes_Class[] An associative array where keys are class URIs and values are + * core_kernel_classes_Class objects. */ public function getTypes() { @@ -287,8 +295,9 @@ public function setComment($comment) * * @access public * @author Joel Bout, - * @param Property property uriProperty is string and may be short in the case of a locally defined property (module namespace), or long uri - * @param array options + * @param core_kernel_classes_Property $property uriProperty is string and may be short in the case of a locally + * defined property (module namespace), or long uri + * @param array $options * @return array */ public function getPropertyValues(core_kernel_classes_Property $property, $options = []) @@ -358,7 +367,9 @@ public function getOnePropertyValue(core_kernel_classes_Property $property, $las { $returnValue = null; if ($last) { - throw new core_kernel_persistence_Exception('parameter \'last\' for getOnePropertyValue no longer supported'); + throw new core_kernel_persistence_Exception( + 'parameter \'last\' for getOnePropertyValue no longer supported' + ); }; $options = [ @@ -595,7 +606,8 @@ public function duplicate($excludedProperties = []) * * @author patrick.plichart@tudor.lu * - * @param bool deleteReference set deleteReference to true when you need that all reference to this resource are removed. + * @param bool $deleteReference set deleteReference to true when you need that all reference to this resource are + * removed. * * @return bool */ diff --git a/core/kernel/classes/class.ResourceFormatter.php b/core/kernel/classes/class.ResourceFormatter.php index 7274b198e..0e8ab32ca 100644 --- a/core/kernel/classes/class.ResourceFormatter.php +++ b/core/kernel/classes/class.ResourceFormatter.php @@ -72,7 +72,9 @@ private function propertiesValuestoStdClasses($propertiesValues = null) foreach ($values as $value) { $stdValue = new stdClass(); $stdValue->valueType = (get_class($value) == "core_kernel_classes_Literal") ? "literal" : "resource"; - $stdValue->value = (get_class($value) == "core_kernel_classes_Literal") ? $value->__toString() : $value->getUri(); + $stdValue->value = (get_class($value) == "core_kernel_classes_Literal") + ? $value->__toString() + : $value->getUri(); $propStdClass->values[] = $stdValue; } $returnValue[] = $propStdClass; diff --git a/core/kernel/classes/class.ResourceIterator.php b/core/kernel/classes/class.ResourceIterator.php index 8cad087f1..262ba509f 100644 --- a/core/kernel/classes/class.ResourceIterator.php +++ b/core/kernel/classes/class.ResourceIterator.php @@ -117,7 +117,8 @@ public function next() $this->currentInstance++; if (!isset($this->instanceCache[$this->currentInstance])) { // try to load next block (unless we know it's empty) - $remainingInstances = !$this->endOfClass && $this->load($this->classIterator->current(), $this->currentInstance); + $remainingInstances = !$this->endOfClass + && $this->load($this->classIterator->current(), $this->currentInstance); // endOfClass or failed loading if (!$remainingInstances) { diff --git a/core/kernel/impl/class.ApiModelOO.php b/core/kernel/impl/class.ApiModelOO.php index 0185dc044..639c87ce6 100644 --- a/core/kernel/impl/class.ApiModelOO.php +++ b/core/kernel/impl/class.ApiModelOO.php @@ -253,7 +253,9 @@ public function setStatement($subject, $predicate, $object, $language) ]); } catch (DBALException $e) { if ($e->getCode() !== '00000') { - throw new common_Exception("Unable to setStatement (SPO) {$subject}, {$predicate}, {$object} : " . $e->getMessage()); + throw new common_Exception( + "Unable to setStatement (SPO) {$subject}, {$predicate}, {$object} : " . $e->getMessage() + ); } } diff --git a/core/kernel/persistence/interface.ClassInterface.php b/core/kernel/persistence/interface.ClassInterface.php index 3227476ab..bcb6c253f 100644 --- a/core/kernel/persistence/interface.ClassInterface.php +++ b/core/kernel/persistence/interface.ClassInterface.php @@ -144,7 +144,12 @@ public function createSubClass(core_kernel_classes_Class $resource, $label = '', * @param boolean isLgDependent * @return core_kernel_classes_Property */ - public function createProperty(core_kernel_classes_Class $resource, $label = '', $comment = '', $isLgDependent = false); + public function createProperty( + core_kernel_classes_Class $resource, + $label = '', + $comment = '', + $isLgDependent = false + ); /** * Short description of method searchInstances @@ -181,7 +186,12 @@ public function countInstances(core_kernel_classes_Class $resource, $propertyFil * @param array options * @return array */ - public function getInstancesPropertyValues(core_kernel_classes_Class $resource, core_kernel_classes_Property $property, $propertyFilters = [], $options = []); + public function getInstancesPropertyValues( + core_kernel_classes_Class $resource, + core_kernel_classes_Property $property, + $propertyFilters = [], + $options = [] + ); /** * Should not be called by application code, please use diff --git a/core/kernel/persistence/interface.ResourceInterface.php b/core/kernel/persistence/interface.ResourceInterface.php index 8639df093..c577aafd9 100644 --- a/core/kernel/persistence/interface.ResourceInterface.php +++ b/core/kernel/persistence/interface.ResourceInterface.php @@ -52,7 +52,11 @@ public function getTypes(core_kernel_classes_Resource $resource); * @param array options * @return array */ - public function getPropertyValues(core_kernel_classes_Resource $resource, core_kernel_classes_Property $property, $options = []); + public function getPropertyValues( + core_kernel_classes_Resource $resource, + core_kernel_classes_Property $property, + $options = [] + ); /** * Short description of method getPropertyValuesByLg @@ -64,7 +68,11 @@ public function getPropertyValues(core_kernel_classes_Resource $resource, core_k * @param string lg * @return core_kernel_classes_ContainerCollection */ - public function getPropertyValuesByLg(core_kernel_classes_Resource $resource, core_kernel_classes_Property $property, $lg); + public function getPropertyValuesByLg( + core_kernel_classes_Resource $resource, + core_kernel_classes_Property $property, + $lg + ); /** * Short description of method setPropertyValue @@ -77,7 +85,12 @@ public function getPropertyValuesByLg(core_kernel_classes_Resource $resource, co * @param string lg * @return boolean */ - public function setPropertyValue(core_kernel_classes_Resource $resource, core_kernel_classes_Property $property, $object, $lg = null); + public function setPropertyValue( + core_kernel_classes_Resource $resource, + core_kernel_classes_Property $property, + $object, + $lg = null + ); /** * Short description of method setPropertiesValues @@ -101,7 +114,12 @@ public function setPropertiesValues(core_kernel_classes_Resource $resource, $pro * @param string lg * @return boolean */ - public function setPropertyValueByLg(core_kernel_classes_Resource $resource, core_kernel_classes_Property $property, $value, $lg); + public function setPropertyValueByLg( + core_kernel_classes_Resource $resource, + core_kernel_classes_Property $property, + $value, + $lg + ); /** * Short description of method removePropertyValues @@ -113,7 +131,11 @@ public function setPropertyValueByLg(core_kernel_classes_Resource $resource, cor * @param array options * @return boolean */ - public function removePropertyValues(core_kernel_classes_Resource $resource, core_kernel_classes_Property $property, $options = []); + public function removePropertyValues( + core_kernel_classes_Resource $resource, + core_kernel_classes_Property $property, + $options = [] + ); /** * Short description of method removePropertyValueByLg @@ -126,7 +148,12 @@ public function removePropertyValues(core_kernel_classes_Resource $resource, cor * @param array options * @return boolean */ - public function removePropertyValueByLg(core_kernel_classes_Resource $resource, core_kernel_classes_Property $property, $lg, $options = []); + public function removePropertyValueByLg( + core_kernel_classes_Resource $resource, + core_kernel_classes_Property $property, + $lg, + $options = [] + ); /** * Short description of method getRdfTriples diff --git a/core/kernel/persistence/newsql/NewSqlRdf.php b/core/kernel/persistence/newsql/NewSqlRdf.php index 5fa5d63ae..e655ed8a7 100644 --- a/core/kernel/persistence/newsql/NewSqlRdf.php +++ b/core/kernel/persistence/newsql/NewSqlRdf.php @@ -43,7 +43,8 @@ class NewSqlRdf extends core_kernel_persistence_smoothsql_SmoothRdf public function add(core_kernel_classes_Triple $triple) { - $query = 'INSERT INTO statements ( id, modelId, subject, predicate, object, l_language, epoch, author) VALUES ( ?, ? , ? , ? , ? , ? , ?, ?);'; + $query = 'INSERT INTO statements ( id, modelId, subject, predicate, object, l_language, epoch, author) VALUES ' + . '( ?, ? , ? , ? , ? , ? , ?, ?);'; $success = $this->getPersistence() ->exec( diff --git a/core/kernel/persistence/smoothsql/class.Class.php b/core/kernel/persistence/smoothsql/class.Class.php index d33556356..b27762948 100644 --- a/core/kernel/persistence/smoothsql/class.Class.php +++ b/core/kernel/persistence/smoothsql/class.Class.php @@ -37,7 +37,8 @@ * Short description of class core_kernel_persistence_smoothsql_Class * */ -class core_kernel_persistence_smoothsql_Class extends core_kernel_persistence_smoothsql_Resource implements core_kernel_persistence_ClassInterface +class core_kernel_persistence_smoothsql_Class extends core_kernel_persistence_smoothsql_Resource implements + core_kernel_persistence_ClassInterface { use EventManagerAwareTrait; @@ -49,8 +50,12 @@ public function getSubClasses(core_kernel_classes_Class $resource, $recursive = { if (!$recursive) { $returnValue = []; - $sqlQuery = 'SELECT subject FROM statements WHERE predicate = ? and ' . $this->getPersistence()->getPlatForm()->getObjectTypeCondition() . ' = ?'; - $sqlResult = $this->getPersistence()->query($sqlQuery, [OntologyRdfs::RDFS_SUBCLASSOF, $resource->getUri()]); + $sqlQuery = 'SELECT subject FROM statements WHERE predicate = ? and ' + . $this->getPersistence()->getPlatForm()->getObjectTypeCondition() . ' = ?'; + $sqlResult = $this->getPersistence()->query( + $sqlQuery, + [OntologyRdfs::RDFS_SUBCLASSOF, $resource->getUri()] + ); while ($row = $sqlResult->fetch()) { $returnValue[$row['subject']] = $this->getModel()->getClass($row['subject']); } @@ -74,8 +79,9 @@ private function getRecursiveSubClasses(core_kernel_classes_Class $resource) foreach ($todo as $class) { $classString .= ", " . $this->getPersistence()->quote($class->getUri()) ; } - $sqlQuery = 'SELECT subject FROM statements WHERE predicate = ? and ' . $this->getPersistence()->getPlatForm()->getObjectTypeCondition() - . ' in (' . substr($classString, 1) . ')'; + $sqlQuery = 'SELECT subject FROM statements WHERE predicate = ? and ' + . $this->getPersistence()->getPlatForm()->getObjectTypeCondition() . ' in (' + . substr($classString, 1) . ')'; $sqlResult = $this->getPersistence()->query($sqlQuery, [OntologyRdfs::RDFS_SUBCLASSOF]); $todo = []; while ($row = $sqlResult->fetch()) { @@ -97,7 +103,8 @@ public function isSubClassOf(core_kernel_classes_Class $resource, core_kernel_cl { $returnValue = false; - $query = 'SELECT object FROM statements WHERE subject = ? AND predicate = ? AND ' . $this->getPersistence()->getPlatForm()->getObjectTypeCondition() . ' = ?'; + $query = 'SELECT object FROM statements WHERE subject = ? AND predicate = ? AND ' + . $this->getPersistence()->getPlatForm()->getObjectTypeCondition() . ' = ?'; $result = $this->getPersistence()->query($query, [ $resource->getUri(), OntologyRdfs::RDFS_SUBCLASSOF, @@ -138,9 +145,15 @@ public function getParentClasses(core_kernel_classes_Class $resource, $recursive $parentClass = $this->getModel()->getClass($row['object']); $returnValue[$parentClass->getUri()] = $parentClass ; - if ($recursive == true && $parentClass->getUri() != OntologyRdfs::RDFS_CLASS && $parentClass->getUri() != OntologyRdfs::RDFS_RESOURCE) { + if ( + $recursive == true + && $parentClass->getUri() != OntologyRdfs::RDFS_CLASS + && $parentClass->getUri() != OntologyRdfs::RDFS_RESOURCE + ) { if ($parentClass->getUri() == GenerisRdf::CLASS_GENERIS_RESOURCE) { - $returnValue[OntologyRdfs::RDFS_RESOURCE] = $this->getModel()->getClass(OntologyRdfs::RDFS_RESOURCE); + $returnValue[OntologyRdfs::RDFS_RESOURCE] = $this->getModel()->getClass( + OntologyRdfs::RDFS_RESOURCE + ); } else { $plop = $parentClass->getParentClasses(true); $returnValue = array_merge($returnValue, $plop); @@ -159,7 +172,8 @@ public function getProperties(core_kernel_classes_Class $resource, $recursive = { $returnValue = []; - $sqlQuery = 'SELECT subject FROM statements WHERE predicate = ? AND ' . $this->getPersistence()->getPlatForm()->getObjectTypeCondition() . ' = ?'; + $sqlQuery = 'SELECT subject FROM statements WHERE predicate = ? AND ' + . $this->getPersistence()->getPlatForm()->getObjectTypeCondition() . ' = ?'; $sqlResult = $this->getPersistence()->query($sqlQuery, [ OntologyRdfs::RDFS_DOMAIN, $resource->getUri() @@ -316,8 +330,12 @@ public function createSubClass(core_kernel_classes_Class $resource, $label = '', * (non-PHPdoc) * @see core_kernel_persistence_ClassInterface::createProperty() */ - public function createProperty(core_kernel_classes_Class $resource, $label = '', $comment = '', $isLgDependent = false) - { + public function createProperty( + core_kernel_classes_Class $resource, + $label = '', + $comment = '', + $isLgDependent = false + ) { $returnValue = null; @@ -387,7 +405,8 @@ public function countInstances(core_kernel_classes_Class $resource, $propertyFil unset($options['order']); } - $query = 'SELECT count(subject) FROM (' . $this->getFilteredQuery($resource, $propertyFilters, $options) . ') as countq'; + $query = 'SELECT count(subject) FROM (' . $this->getFilteredQuery($resource, $propertyFilters, $options) + . ') as countq'; return (int)$this->getPersistence()->query($query)->fetchColumn(); } @@ -395,8 +414,12 @@ public function countInstances(core_kernel_classes_Class $resource, $propertyFil * (non-PHPdoc) * @see core_kernel_persistence_ClassInterface::getInstancesPropertyValues() */ - public function getInstancesPropertyValues(core_kernel_classes_Class $resource, core_kernel_classes_Property $property, $propertyFilters = [], $options = []) - { + public function getInstancesPropertyValues( + core_kernel_classes_Class $resource, + core_kernel_classes_Property $property, + $propertyFilters = [], + $options = [] + ) { $returnValue = []; $distinct = isset($options['distinct']) ? $options['distinct'] : false; @@ -413,7 +436,8 @@ public function getInstancesPropertyValues(core_kernel_classes_Class $resource, $query .= ' DISTINCT'; } - $query .= " object FROM (SELECT overq.subject, valuesq.object FROM (${filteredQuery}) as overq JOIN statements AS valuesq ON (overq.subject = valuesq.subject AND valuesq.predicate = ?)) AS overrootq"; + $query .= " object FROM (SELECT overq.subject, valuesq.object FROM (${filteredQuery}) as overq JOIN statements " + . "AS valuesq ON (overq.subject = valuesq.subject AND valuesq.predicate = ?)) AS overrootq"; $sqlResult = $this->getPersistence()->query($query, [$property->getUri()]); while ($row = $sqlResult->fetch()) { @@ -445,11 +469,15 @@ public function createInstanceWithProperties(core_kernel_classes_Class $type, $p $returnValue = null; if (isset($properties[OntologyRdf::RDF_TYPE])) { - throw new core_kernel_persistence_Exception('Additional types in createInstanceWithProperties not permited'); + throw new core_kernel_persistence_Exception( + 'Additional types in createInstanceWithProperties not permited' + ); } $properties[OntologyRdf::RDF_TYPE] = $type; - $returnValue = $this->getModel()->getResource($this->getServiceLocator()->get(UriProvider::SERVICE_ID)->provide()); + $returnValue = $this->getModel()->getResource( + $this->getServiceLocator()->get(UriProvider::SERVICE_ID)->provide() + ); $returnValue->setPropertiesValues($properties); return $returnValue; @@ -486,7 +514,9 @@ public function deleteInstances(core_kernel_classes_Class $resource, $resources, $this->getPersistence()->exec($query); $returnValue = true; } catch (DBALException $e) { - throw new core_kernel_persistence_smoothsql_Exception("An error occured while deleting resources: " . $e->getMessage()); + throw new core_kernel_persistence_smoothsql_Exception( + "An error occured while deleting resources: " . $e->getMessage() + ); } } @@ -524,7 +554,9 @@ public function getFilteredQuery(core_kernel_classes_Class $resource, $propertyF $rdftypes[] = $resource->getUri(); } - $and = (isset($options['chaining']) === false) ? true : ((strtolower($options['chaining']) === 'and') ? true : false); + $and = (isset($options['chaining']) === false) + ? true + : ((strtolower($options['chaining']) === 'and') ? true : false); $like = (isset($options['like']) === false) ? true : $options['like']; $lang = (isset($options['lang']) === false) ? '' : $options['lang']; $offset = (isset($options['offset']) === false) ? 0 : $options['offset']; @@ -534,9 +566,31 @@ public function getFilteredQuery(core_kernel_classes_Class $resource, $propertyF if ($this->getServiceLocator()->has(ComplexSearchService::SERVICE_ID)) { $search = $this->getModel()->getSearchInterface(); - $query = $search->getQuery($this->getModel(), $rdftypes, $propertyFilters, $and, $like, $lang, $offset, $limit, $order, $orderdir); + $query = $search->getQuery( + $this->getModel(), + $rdftypes, + $propertyFilters, + $and, + $like, + $lang, + $offset, + $limit, + $order, + $orderdir + ); } else { - $query = core_kernel_persistence_smoothsql_Utils::buildFilterQuery($this->getModel(), $rdftypes, $propertyFilters, $and, $like, $lang, $offset, $limit, $order, $orderdir); + $query = core_kernel_persistence_smoothsql_Utils::buildFilterQuery( + $this->getModel(), + $rdftypes, + $propertyFilters, + $and, + $like, + $lang, + $offset, + $limit, + $order, + $orderdir + ); } return $query; diff --git a/core/kernel/persistence/smoothsql/class.Property.php b/core/kernel/persistence/smoothsql/class.Property.php index b4fa6d6b1..b34d43a81 100644 --- a/core/kernel/persistence/smoothsql/class.Property.php +++ b/core/kernel/persistence/smoothsql/class.Property.php @@ -37,7 +37,8 @@ * @package generis */ -class core_kernel_persistence_smoothsql_Property extends core_kernel_persistence_smoothsql_Resource implements core_kernel_persistence_PropertyInterface +class core_kernel_persistence_smoothsql_Property extends core_kernel_persistence_smoothsql_Resource implements + core_kernel_persistence_PropertyInterface { // --- ASSOCIATIONS --- @@ -87,7 +88,10 @@ public function isLgDependent(core_kernel_classes_Resource $resource) public function isMultiple(core_kernel_classes_Resource $resource) { $returnValue = (bool) false; - throw new core_kernel_persistence_ProhibitedFunctionException("not implemented => The function (" . __METHOD__ . ") is not available in this persistence implementation (" . __CLASS__ . ")"); + throw new core_kernel_persistence_ProhibitedFunctionException( + "not implemented => The function (" . __METHOD__ + . ") is not available in this persistence implementation (" . __CLASS__ . ")" + ); return (bool) $returnValue; } @@ -102,7 +106,10 @@ public function isMultiple(core_kernel_classes_Resource $resource) public function getRange(core_kernel_classes_Resource $resource) { $returnValue = null; - throw new core_kernel_persistence_ProhibitedFunctionException("not implemented => The function (" . __METHOD__ . ") is not available in this persistence implementation (" . __CLASS__ . ")"); + throw new core_kernel_persistence_ProhibitedFunctionException( + "not implemented => The function (" . __METHOD__ + . ") is not available in this persistence implementation (" . __CLASS__ . ")" + ); return $returnValue; } diff --git a/core/kernel/persistence/smoothsql/class.Resource.php b/core/kernel/persistence/smoothsql/class.Resource.php index 00c209297..533167d16 100644 --- a/core/kernel/persistence/smoothsql/class.Resource.php +++ b/core/kernel/persistence/smoothsql/class.Resource.php @@ -113,8 +113,11 @@ public function getTypes(core_kernel_classes_Resource $resource) * @throws core_kernel_persistence_Exception * @author Joel Bout, */ - public function getPropertyValues(core_kernel_classes_Resource $resource, core_kernel_classes_Property $property, $options = []) - { + public function getPropertyValues( + core_kernel_classes_Resource $resource, + core_kernel_classes_Property $property, + $options = [] + ) { $returnValue = []; $one = isset($options['one']) && $options['one'] == true ? true : false; @@ -159,8 +162,15 @@ public function getPropertyValues(core_kernel_classes_Resource $resource, core_k $returnValue[] = $this->getPersistence()->getPlatForm()->getPhpTextValue($row['object']); } } else { - // Filter result by language and return one set of values (User language in top priority, default language in second and the fallback language (null) in third) - $returnValue = core_kernel_persistence_smoothsql_Utils::filterByLanguage($this->getPersistence(), $result->fetchAll(), 'l_language', $lang, $default); + // Filter result by language and return one set of values (User language in top priority, default + // language in second and the fallback language (null) in third) + $returnValue = core_kernel_persistence_smoothsql_Utils::filterByLanguage( + $this->getPersistence(), + $result->fetchAll(), + 'l_language', + $lang, + $default + ); } } @@ -178,8 +188,11 @@ public function getPropertyValues(core_kernel_classes_Resource $resource, core_k * @throws core_kernel_persistence_Exception * @author Joel Bout, */ - public function getPropertyValuesByLg(core_kernel_classes_Resource $resource, core_kernel_classes_Property $property, $lg) - { + public function getPropertyValuesByLg( + core_kernel_classes_Resource $resource, + core_kernel_classes_Property $property, + $lg + ) { $options = ['lg' => $lg]; $returnValue = new core_kernel_classes_ContainerCollection($resource); @@ -201,8 +214,12 @@ public function getPropertyValuesByLg(core_kernel_classes_Resource $resource, co * @return boolean * @author Joel Bout, */ - public function setPropertyValue(core_kernel_classes_Resource $resource, core_kernel_classes_Property $property, $object, $lg = null) - { + public function setPropertyValue( + core_kernel_classes_Resource $resource, + core_kernel_classes_Property $property, + $object, + $lg = null + ) { $object = $object instanceof core_kernel_classes_Resource ? $object->getUri() : (string) $object; if ($property->isLgDependent()) { $lang = ((null != $lg) @@ -266,8 +283,12 @@ public function setPropertiesValues(core_kernel_classes_Resource $resource, $pro * @return boolean * @author Joel Bout, */ - public function setPropertyValueByLg(core_kernel_classes_Resource $resource, core_kernel_classes_Property $property, $value, $lg) - { + public function setPropertyValueByLg( + core_kernel_classes_Resource $resource, + core_kernel_classes_Property $property, + $value, + $lg + ) { $triple = core_kernel_classes_Triple::createTriple( $this->getNewTripleModelId(), $resource->getUri(), @@ -288,8 +309,11 @@ public function setPropertyValueByLg(core_kernel_classes_Resource $resource, cor * @return boolean * @author Joel Bout, */ - public function removePropertyValues(core_kernel_classes_Resource $resource, core_kernel_classes_Property $property, $options = []) - { + public function removePropertyValues( + core_kernel_classes_Resource $resource, + core_kernel_classes_Property $property, + $options = [] + ) { // Optional params $pattern = isset($options['pattern']) && !is_null($options['pattern']) ? $options['pattern'] : null; $like = isset($options['like']) && $options['like'] == true ? true : false; @@ -301,14 +325,22 @@ public function removePropertyValues(core_kernel_classes_Resource $resource, cor $conditions = []; if (is_string($pattern)) { if (!is_null($pattern)) { - $searchPattern = core_kernel_persistence_smoothsql_Utils::buildSearchPattern($this->getPersistence(), $pattern, $like); + $searchPattern = core_kernel_persistence_smoothsql_Utils::buildSearchPattern( + $this->getPersistence(), + $pattern, + $like + ); $conditions[] = '( ' . $objectType . ' ' . $searchPattern . ' )'; } } elseif (is_array($pattern)) { if (count($pattern) > 0) { $multiCondition = "( "; foreach ($pattern as $i => $patternToken) { - $searchPattern = core_kernel_persistence_smoothsql_Utils::buildSearchPattern($this->getPersistence(), $patternToken, $like); + $searchPattern = core_kernel_persistence_smoothsql_Utils::buildSearchPattern( + $this->getPersistence(), + $patternToken, + $like + ); if ($i > 0) { $multiCondition .= " OR "; } @@ -358,8 +390,12 @@ public function removePropertyValues(core_kernel_classes_Resource $resource, cor * @return boolean * @author Joel Bout, */ - public function removePropertyValueByLg(core_kernel_classes_Resource $resource, core_kernel_classes_Property $property, $lg, $options = []) - { + public function removePropertyValueByLg( + core_kernel_classes_Resource $resource, + core_kernel_classes_Property $property, + $lg, + $options = [] + ) { $sqlQuery = 'DELETE FROM statements WHERE subject = ? and predicate = ? and l_language = ?'; //be sure the property we try to remove is included in an updatable model $sqlQuery .= ' AND ' . $this->getModelWriteSqlCondition(); @@ -388,7 +424,8 @@ public function removePropertyValueByLg(core_kernel_classes_Resource $resource, public function getRdfTriples(core_kernel_classes_Resource $resource) { // TODO: refactor this to use a triple store abstraction - $query = 'SELECT * FROM statements WHERE subject = ? AND ' . $this->getModelReadSqlCondition() . ' ORDER BY predicate'; + $query = 'SELECT * FROM statements WHERE subject = ? AND ' . $this->getModelReadSqlCondition() + . ' ORDER BY predicate'; $result = $this->getPersistence()->query($query, [$resource->getUri()]); $returnValue = new core_kernel_classes_ContainerCollection(new common_Object(__METHOD__)); @@ -499,7 +536,9 @@ public function delete(core_kernel_classes_Resource $resource, $deleteReference if (!$returnValue) { $returnValue = false; } elseif ($deleteReference) { - $sqlQuery = 'DELETE FROM statements WHERE ' . $this->getPersistence()->getPlatForm()->getObjectTypeCondition() . ' = ? AND ' . $this->getModelWriteSqlCondition(); + $sqlQuery = 'DELETE FROM statements WHERE ' + . $this->getPersistence()->getPlatForm()->getObjectTypeCondition() . ' = ? AND ' + . $this->getModelWriteSqlCondition(); $return = $this->getPersistence()->exec($sqlQuery, [$resource->getUri()]); if ($return !== false) { @@ -591,8 +630,8 @@ public function setType(core_kernel_classes_Resource $resource, core_kernel_clas */ public function removeType(core_kernel_classes_Resource $resource, core_kernel_classes_Class $class) { - $query = 'DELETE FROM statements - WHERE subject = ? AND predicate = ? AND ' . $this->getPersistence()->getPlatForm()->getObjectTypeCondition() . ' = ?'; + $query = 'DELETE FROM statements WHERE subject = ? AND predicate = ? AND ' + . $this->getPersistence()->getPlatForm()->getObjectTypeCondition() . ' = ?'; //be sure the property we try to remove is included in an updatable model $query .= ' AND ' . $this->getModelWriteSqlCondition(); diff --git a/core/kernel/persistence/smoothsql/class.SmoothModel.php b/core/kernel/persistence/smoothsql/class.SmoothModel.php index 255b9937e..cef6f2d9c 100755 --- a/core/kernel/persistence/smoothsql/class.SmoothModel.php +++ b/core/kernel/persistence/smoothsql/class.SmoothModel.php @@ -34,7 +34,9 @@ * @author joel bout * @package generis */ -class core_kernel_persistence_smoothsql_SmoothModel extends ConfigurableService implements Ontology, SchemaProviderInterface +class core_kernel_persistence_smoothsql_SmoothModel extends ConfigurableService implements + Ontology, + SchemaProviderInterface { public const OPTION_PERSISTENCE = 'persistence'; public const OPTION_READABLE_MODELS = 'readable'; @@ -186,7 +188,9 @@ public static function getReadableModelIds() { $model = ModelManager::getModel(); if (!$model instanceof self) { - throw new common_exception_Error(__FUNCTION__ . ' called on ' . get_class($model) . ' model implementation'); + throw new common_exception_Error( + __FUNCTION__ . ' called on ' . get_class($model) . ' model implementation' + ); } return $model->getReadableModels(); } @@ -201,7 +205,9 @@ public static function getUpdatableModelIds() { $model = ModelManager::getModel(); if (!$model instanceof self) { - throw new common_exception_Error(__FUNCTION__ . ' called on ' . get_class($model) . ' model implementation'); + throw new common_exception_Error( + __FUNCTION__ . ' called on ' . get_class($model) . ' model implementation' + ); } return $model->getWritableModels(); } diff --git a/core/kernel/persistence/smoothsql/class.SmoothRdf.php b/core/kernel/persistence/smoothsql/class.SmoothRdf.php index c1d6d186c..dda69ced7 100644 --- a/core/kernel/persistence/smoothsql/class.SmoothRdf.php +++ b/core/kernel/persistence/smoothsql/class.SmoothRdf.php @@ -144,7 +144,15 @@ protected function insertValues(array $valuesToInsert) public function remove(core_kernel_classes_Triple $triple) { $query = "DELETE FROM statements WHERE subject = ? AND predicate = ? AND object = ? AND l_language = ?;"; - return $this->getPersistence()->exec($query, [$triple->subject, $triple->predicate, $triple->object, is_null($triple->lg) ? '' : $triple->lg]); + return $this->getPersistence()->exec( + $query, + [ + $triple->subject, + $triple->predicate, + $triple->object, + is_null($triple->lg) ? '' : $triple->lg + ] + ); } /** diff --git a/core/kernel/persistence/smoothsql/class.Utils.php b/core/kernel/persistence/smoothsql/class.Utils.php index a7140f89b..cb3076f13 100644 --- a/core/kernel/persistence/smoothsql/class.Utils.php +++ b/core/kernel/persistence/smoothsql/class.Utils.php @@ -101,12 +101,17 @@ public static function getFirstLanguage($values) /** * Filter a $dataset by language. * - * @param mixed dataset - * @param string langColname + * @param mixed $dataset + * @param string $langColname * @return array */ - public static function filterByLanguage(common_persistence_SqlPersistence $persistence, $dataset, $langColname, $selectedLanguage, $defaultLanguage) - { + public static function filterByLanguage( + common_persistence_SqlPersistence $persistence, + $dataset, + $langColname, + $selectedLanguage, + $defaultLanguage + ) { $returnValue = []; $result = self::sortByLanguage($persistence, $dataset, $langColname, $selectedLanguage, $defaultLanguage); @@ -147,8 +152,9 @@ public static function identifyFirstLanguage($values) /** * Build a SQL search pattern on basis of a pattern and a comparison mode. * - * @param tring pattern A value to compare. - * @param boolean like The manner to compare values. If set to true, the LIKE SQL operator will be used. If set to false, the = (equal) SQL operator will be used. + * @param string $pattern A value to compare. + * @param boolean $like The manner to compare values. If set to true, the LIKE SQL operator will be used. If set + * to false, the = (equal) SQL operator will be used. * @return string */ public static function buildSearchPattern(common_persistence_SqlPersistence $persistence, $pattern, $like = true) @@ -194,8 +200,13 @@ public static function buildSearchPattern(common_persistence_SqlPersistence $per return $returnValue; } - public static function buildPropertyQuery(core_kernel_persistence_smoothsql_SmoothModel $model, $propertyUri, $values, $like, $lang = '') - { + public static function buildPropertyQuery( + core_kernel_persistence_smoothsql_SmoothModel $model, + $propertyUri, + $values, + $like, + $lang = '' + ) { $persistence = $model->getPersistence(); // Deal with predicate... @@ -257,8 +268,18 @@ public static function buildUnionQuery($propertyQueries) } } - public static function buildFilterQuery(core_kernel_persistence_smoothsql_SmoothModel $model, $classUri, array $propertyFilters, $and = true, $like = true, $lang = '', $offset = 0, $limit = 0, $order = '', $orderDir = 'ASC') - { + public static function buildFilterQuery( + core_kernel_persistence_smoothsql_SmoothModel $model, + $classUri, + array $propertyFilters, + $and = true, + $like = true, + $lang = '', + $offset = 0, + $limit = 0, + $order = '', + $orderDir = 'ASC' + ) { $orderDir = self::sanitizeOrderDirection($orderDir); diff --git a/core/kernel/persistence/smoothsql/search/ComplexSearchService.php b/core/kernel/persistence/smoothsql/search/ComplexSearchService.php index c5a15450b..2d4f0e7b5 100755 --- a/core/kernel/persistence/smoothsql/search/ComplexSearchService.php +++ b/core/kernel/persistence/smoothsql/search/ComplexSearchService.php @@ -223,8 +223,18 @@ protected function validValue($value) * @param string $orderDir * @return string */ - public function getQuery(core_kernel_persistence_smoothsql_SmoothModel $model, $classUri, array $propertyFilters, $and = true, $isLikeOperator = true, $lang = '', $offset = 0, $limit = 0, $order = '', $orderDir = 'ASC') - { + public function getQuery( + core_kernel_persistence_smoothsql_SmoothModel $model, + $classUri, + array $propertyFilters, + $and = true, + $isLikeOperator = true, + $lang = '', + $offset = 0, + $limit = 0, + $order = '', + $orderDir = 'ASC' + ) { $query = $this->getGateway()->query()->setLimit($limit)->setOffset($offset); if (!empty($order)) { diff --git a/core/kernel/persistence/smoothsql/search/QueryJoiner.php b/core/kernel/persistence/smoothsql/search/QueryJoiner.php index 68e278105..be88e447a 100644 --- a/core/kernel/persistence/smoothsql/search/QueryJoiner.php +++ b/core/kernel/persistence/smoothsql/search/QueryJoiner.php @@ -41,7 +41,12 @@ * * @author Christophe GARCIA */ -class QueryJoiner implements DriverSensitiveInterface, SortableInterface, LimitableInterface, ParentFluateInterface, OptionsInterface +class QueryJoiner implements + DriverSensitiveInterface, + SortableInterface, + LimitableInterface, + ParentFluateInterface, + OptionsInterface { use SortableTrait; @@ -177,7 +182,8 @@ public function setLanguageCondition($language, $emptyAvailable = false) $sql = ' AND ( '; $sql .= $languageField . ' = ' . $this->getDriverEscaper()->quote($languageValue) . ''; if ($emptyAvailable) { - $sql .= ' ' . $this->getDriverEscaper()->dbCommand('OR') . ' ' . $languageField . ' = ' . $this->getDriverEscaper()->getEmpty(); + $sql .= ' ' . $this->getDriverEscaper()->dbCommand('OR') . ' ' . $languageField . ' = ' + . $this->getDriverEscaper()->getEmpty(); } $sql .= ' ) '; return $sql; @@ -195,10 +201,13 @@ protected function sortedQuery($main, $join) $aggrObject = $this->getDriverEscaper()->reserved('J') . '.' . $this->getDriverEscaper()->reserved('object'); - $query = $this->getDriverEscaper()->dbCommand('SELECT') . ' ' . $this->getDriverEscaper()->reserved('subject') . ' ' . - $this->getDriverEscaper()->dbCommand('FROM') . ' ( ' . - $this->getDriverEscaper()->dbCommand('SELECT') . ' ' . $this->getDriverEscaper()->dbCommand('DISTINCT') . ' ' . - $this->getDriverEscaper()->reserved('T') . '.' . $this->getDriverEscaper()->reserved('subject') . ' , '; + $query = $this->getDriverEscaper()->dbCommand('SELECT') . ' ' + . $this->getDriverEscaper()->reserved('subject') . ' ' + . $this->getDriverEscaper()->dbCommand('FROM') . ' ( ' + . $this->getDriverEscaper()->dbCommand('SELECT') . ' ' + . $this->getDriverEscaper()->dbCommand('DISTINCT') . ' ' + . $this->getDriverEscaper()->reserved('T') . '.' + . $this->getDriverEscaper()->reserved('subject') . ' , '; $sortKeys = []; @@ -216,19 +225,24 @@ protected function sortedQuery($main, $join) $index++; } - $query .= implode(' , ', $sortKeys) . ' ' . $this->getDriverEscaper()->dbCommand('FROM') . ' ( ' . - $main . ' )' . - $this->getDriverEscaper()->dbCommand('AS') . ' ' . $this->getDriverEscaper()->reserved('T') . - $this->getDriverEscaper()->dbCommand('JOIN') . ' ( ' . - $this->getDriverEscaper()->dbCommand('SELECT') . ' ' . $this->getDriverEscaper()->reserved('subject') . ' , ' . - $this->getDriverEscaper()->reserved('object') . ' ' . $this->getDriverEscaper()->dbCommand('FROM') . ' ' . - $this->getDriverEscaper()->reserved('statements') . ' ' . $this->getDriverEscaper()->dbCommand('WHERE') . ' ' . - $this->getDriverEscaper()->reserved('predicate') . ' = ' . - $this->getDriverEscaper()->quote($this->getDriverEscaper()->escape($this->on)) . ' ) ' . - $this->getDriverEscaper()->dbCommand('AS') . ' ' . $this->getDriverEscaper()->reserved('R') . - $this->getDriverEscaper()->dbCommand('ON') . ' ( ' . - $this->getDriverEscaper()->reserved('T') . '.' . $this->getDriverEscaper()->reserved('subject') . ' = ' . - $this->getDriverEscaper()->reserved('R') . '.' . $this->getDriverEscaper()->reserved('subject') . ' ) '; + $query .= implode(' , ', $sortKeys) . ' ' + . $this->getDriverEscaper()->dbCommand('FROM') . ' ( ' . $main . ' )' + . $this->getDriverEscaper()->dbCommand('AS') . ' ' + . $this->getDriverEscaper()->reserved('T') . $this->getDriverEscaper()->dbCommand('JOIN') + . ' ( ' . $this->getDriverEscaper()->dbCommand('SELECT') . ' ' + . $this->getDriverEscaper()->reserved('subject') . ' , ' + . $this->getDriverEscaper()->reserved('object') . ' ' + . $this->getDriverEscaper()->dbCommand('FROM') . ' ' + . $this->getDriverEscaper()->reserved('statements') . ' ' + . $this->getDriverEscaper()->dbCommand('WHERE') . ' ' + . $this->getDriverEscaper()->reserved('predicate') . ' = ' + . $this->getDriverEscaper()->quote($this->getDriverEscaper()->escape($this->on)) . ' ) ' + . $this->getDriverEscaper()->dbCommand('AS') . ' ' + . $this->getDriverEscaper()->reserved('R') . $this->getDriverEscaper()->dbCommand('ON') + . ' ( ' . $this->getDriverEscaper()->reserved('T') . '.' + . $this->getDriverEscaper()->reserved('subject') . ' = ' + . $this->getDriverEscaper()->reserved('R') . '.' + . $this->getDriverEscaper()->reserved('subject') . ' ) '; $index = 1; @@ -238,40 +252,56 @@ protected function sortedQuery($main, $join) $orderSub = 'SUBJ' . $index; $orderAlias = 'ORDERJ' . $index; - $query .= $this->getDriverEscaper()->dbCommand('JOIN') . ' ( ' . - $this->getDriverEscaper()->dbCommand('SELECT') . ' ' . - $this->getDriverEscaper()->reserved($orderAlias) . '.' . $this->getDriverEscaper()->reserved('subject') . ' , ' . - $this->getDriverEscaper()->reserved($orderAlias) . '.' . $this->getDriverEscaper()->reserved('object') . ' ' . - $this->getDriverEscaper()->dbCommand('FROM') . ' ( ' . - $join . ')' . - $this->getDriverEscaper()->dbCommand('AS') . ' ' . $this->getDriverEscaper()->reserved($orderSub) . ' ' . - $this->getDriverEscaper()->dbCommand('JOIN') . ' ( ' . - $this->getDriverEscaper()->dbCommand('SELECT') . ' ' . $this->getDriverEscaper()->reserved('subject') . ' , ' . - $this->getDriverEscaper()->reserved('object') . ' ' . $this->getDriverEscaper()->dbCommand('FROM') . ' ' . - $this->getDriverEscaper()->reserved('statements') . ' ' . $this->getDriverEscaper()->dbCommand('WHERE') . ' ' . - $this->getDriverEscaper()->reserved('predicate') . ' = ' . - $this->getDriverEscaper()->quote($this->getDriverEscaper()->escape($predicate)) . ' ' . - $this->getLanguage() . ' ' . $this->getDriverEscaper()->dbCommand('GROUP') . ' ' . $this->getDriverEscaper()->dbCommand('BY') . ' ' . - $this->getDriverEscaper()->reserved('subject') . ' , ' . - $this->getDriverEscaper()->reserved('object') . ' ) ' . - $this->getDriverEscaper()->dbCommand('AS') . ' ' . $this->getDriverEscaper()->reserved($orderAlias) . ' ' . - $this->getDriverEscaper()->dbCommand('ON') . ' ( ' . - $this->getDriverEscaper()->reserved($orderSub) . '.' . $this->getDriverEscaper()->reserved('subject') . ' = ' . - $this->getDriverEscaper()->reserved($orderAlias) . '.' . $this->getDriverEscaper()->reserved('subject') . ' ) ) ' . - $this->getDriverEscaper()->dbCommand('AS') . ' ' . $this->getDriverEscaper()->reserved($alias) . ' ' . - $this->getDriverEscaper()->dbCommand('ON') . ' ( ' . - $this->getDriverEscaper()->reserved($alias) . '.' . $this->getDriverEscaper()->reserved('subject') . ' = ' . - $this->getDriverEscaper()->reserved('R') . '.' . $this->getDriverEscaper()->reserved('object') . ' ) '; - - $sortBy[] = $this->getDriverEscaper()->reserved('sorter' . $index) . ' ' . $this->getDriverEscaper()->dbCommand($sortOrder); + $query .= $this->getDriverEscaper()->dbCommand('JOIN') . ' ( ' + . $this->getDriverEscaper()->dbCommand('SELECT') . ' ' + . $this->getDriverEscaper()->reserved($orderAlias) . '.' + . $this->getDriverEscaper()->reserved('subject') . ' , ' + . $this->getDriverEscaper()->reserved($orderAlias) . '.' + . $this->getDriverEscaper()->reserved('object') . ' ' + . $this->getDriverEscaper()->dbCommand('FROM') . ' ( ' . $join . ')' + . $this->getDriverEscaper()->dbCommand('AS') . ' ' + . $this->getDriverEscaper()->reserved($orderSub) . ' ' + . $this->getDriverEscaper()->dbCommand('JOIN') . ' ( ' + . $this->getDriverEscaper()->dbCommand('SELECT') . ' ' + . $this->getDriverEscaper()->reserved('subject') . ' , ' + . $this->getDriverEscaper()->reserved('object') . ' ' + . $this->getDriverEscaper()->dbCommand('FROM') . ' ' + . $this->getDriverEscaper()->reserved('statements') . ' ' + . $this->getDriverEscaper()->dbCommand('WHERE') . ' ' + . $this->getDriverEscaper()->reserved('predicate') . ' = ' + . $this->getDriverEscaper()->quote($this->getDriverEscaper()->escape($predicate)) . ' ' + . $this->getLanguage() . ' ' . $this->getDriverEscaper()->dbCommand('GROUP') . ' ' + . $this->getDriverEscaper()->dbCommand('BY') . ' ' + . $this->getDriverEscaper()->reserved('subject') . ' , ' + . $this->getDriverEscaper()->reserved('object') . ' ) ' + . $this->getDriverEscaper()->dbCommand('AS') . ' ' + . $this->getDriverEscaper()->reserved($orderAlias) . ' ' + . $this->getDriverEscaper()->dbCommand('ON') . ' ( ' + . $this->getDriverEscaper()->reserved($orderSub) . '.' + . $this->getDriverEscaper()->reserved('subject') . ' = ' + . $this->getDriverEscaper()->reserved($orderAlias) . '.' + . $this->getDriverEscaper()->reserved('subject') . ' ) ) ' + . $this->getDriverEscaper()->dbCommand('AS') . ' ' + . $this->getDriverEscaper()->reserved($alias) . ' ' + . $this->getDriverEscaper()->dbCommand('ON') . ' ( ' + . $this->getDriverEscaper()->reserved($alias) . '.' + . $this->getDriverEscaper()->reserved('subject') . ' = ' + . $this->getDriverEscaper()->reserved('R') . '.' + . $this->getDriverEscaper()->reserved('object') . ' ) '; + + $sortBy[] = $this->getDriverEscaper()->reserved('sorter' . $index) . ' ' + . $this->getDriverEscaper()->dbCommand($sortOrder); $index++; } - $query .= $this->getDriverEscaper()->dbCommand('GROUP') . ' ' . $this->getDriverEscaper()->dbCommand('BY') . ' ' . - $this->getDriverEscaper()->reserved('T') . '.' . $this->getDriverEscaper()->reserved('subject') . ' ' . - $this->getDriverEscaper()->dbCommand('ORDER') . ' ' . $this->getDriverEscaper()->dbCommand('BY') . ' ' . - implode(' , ', $sortBy) . ' ) ' . - $this->getDriverEscaper()->dbCommand('AS') . ' ' . $this->getDriverEscaper()->reserved('rootq'); + $query .= $this->getDriverEscaper()->dbCommand('GROUP') . ' ' + . $this->getDriverEscaper()->dbCommand('BY') . ' ' + . $this->getDriverEscaper()->reserved('T') . '.' + . $this->getDriverEscaper()->reserved('subject') . ' ' + . $this->getDriverEscaper()->dbCommand('ORDER') . ' ' + . $this->getDriverEscaper()->dbCommand('BY') . ' ' . implode(' , ', $sortBy) . ' ) ' + . $this->getDriverEscaper()->dbCommand('AS') . ' ' + . $this->getDriverEscaper()->reserved('rootq'); return ($query); } @@ -284,38 +314,42 @@ protected function sortedQuery($main, $join) */ protected function unSortedQuery($main, $join) { - - $query = $this->getDriverEscaper()->dbCommand('SELECT') . ' ' . - $this->getDriverEscaper()->dbCommand('DISTINCT') . ' ' . - $this->getDriverEscaper()->reserved('A') . '.' . - $this->getDriverEscaper()->reserved('subject') . ' ' . - $this->getDriverEscaper()->dbCommand('FROM') . ' ' . - '(' . $main . ')' . $this->getDriverEscaper()->dbCommand('AS') . ' ' . - $this->getDriverEscaper()->reserved('A') . ' ' . - $this->getDriverEscaper()->dbCommand('JOIN') . ' ' . - '(' . $this->getDriverEscaper()->dbCommand('SELECT') . ' ' . - $this->getDriverEscaper()->reserved('subject') . ' , ' . $this->getDriverEscaper()->reserved('object') . ' ' . - $this->getDriverEscaper()->dbCommand('FROM') . ' ' . $this->getDriverEscaper()->reserved('statements') . ' ' . - $this->getDriverEscaper()->dbCommand('WHERE') . ' ' . - $this->getDriverEscaper()->reserved('predicate') . ' = ' . - $this->getDriverEscaper()->quote($this->getDriverEscaper()->escape($this->on)) . ') ' . - $this->getDriverEscaper()->dbCommand('AS') . ' ' . $this->getDriverEscaper()->reserved('R') . ' ' . - $this->getDriverEscaper()->dbCommand('ON') . - ' (' . $this->getDriverEscaper()->reserved('A') . '.' . - $this->getDriverEscaper()->reserved('subject') . ' = ' . - $this->getDriverEscaper()->reserved('R') . '.' . - $this->getDriverEscaper()->reserved('subject') . ') ' . - $this->getDriverEscaper()->dbCommand('JOIN') . ' (' . - $this->getDriverEscaper()->dbCommand('SELECT') . ' ' . - $this->getDriverEscaper()->reserved('subject') . ' ' . - $this->getDriverEscaper()->dbCommand('FROM') . ' ' . - '(' . $join . ')' . $this->getDriverEscaper()->dbCommand('AS') . ' ' . - $this->getDriverEscaper()->reserved('sd') . ' ) ' . - $this->getDriverEscaper()->dbCommand('AS') . ' ' . - $this->getDriverEscaper()->reserved('D') . ' ' . - $this->getDriverEscaper()->dbCommand('ON') . - '(' . $this->getDriverEscaper()->reserved('D') . '.' . $this->getDriverEscaper()->reserved('subject') . - ' = ' . $this->getDriverEscaper()->reserved('R') . '.' . $this->getDriverEscaper()->reserved('object') . ')'; + $query = $this->getDriverEscaper()->dbCommand('SELECT') . ' ' + . $this->getDriverEscaper()->dbCommand('DISTINCT') . ' ' + . $this->getDriverEscaper()->reserved('A') . '.' + . $this->getDriverEscaper()->reserved('subject') . ' ' + . $this->getDriverEscaper()->dbCommand('FROM') . ' (' . $main . ')' + . $this->getDriverEscaper()->dbCommand('AS') . ' ' + . $this->getDriverEscaper()->reserved('A') . ' ' + . $this->getDriverEscaper()->dbCommand('JOIN') . ' (' + . $this->getDriverEscaper()->dbCommand('SELECT') . ' ' + . $this->getDriverEscaper()->reserved('subject') . ' , ' + . $this->getDriverEscaper()->reserved('object') . ' ' + . $this->getDriverEscaper()->dbCommand('FROM') . ' ' + . $this->getDriverEscaper()->reserved('statements') . ' ' + . $this->getDriverEscaper()->dbCommand('WHERE') . ' ' + . $this->getDriverEscaper()->reserved('predicate') . ' = ' + . $this->getDriverEscaper()->quote($this->getDriverEscaper()->escape($this->on)) . ') ' + . $this->getDriverEscaper()->dbCommand('AS') . ' ' + . $this->getDriverEscaper()->reserved('R') . ' ' + . $this->getDriverEscaper()->dbCommand('ON') . ' (' + . $this->getDriverEscaper()->reserved('A') . '.' + . $this->getDriverEscaper()->reserved('subject') . ' = ' + . $this->getDriverEscaper()->reserved('R') . '.' + . $this->getDriverEscaper()->reserved('subject') . ') ' + . $this->getDriverEscaper()->dbCommand('JOIN') . ' (' + . $this->getDriverEscaper()->dbCommand('SELECT') . ' ' + . $this->getDriverEscaper()->reserved('subject') . ' ' + . $this->getDriverEscaper()->dbCommand('FROM') . ' ' . '(' . $join . ')' + . $this->getDriverEscaper()->dbCommand('AS') . ' ' + . $this->getDriverEscaper()->reserved('sd') . ' ) ' + . $this->getDriverEscaper()->dbCommand('AS') . ' ' + . $this->getDriverEscaper()->reserved('D') . ' ' + . $this->getDriverEscaper()->dbCommand('ON') . '(' + . $this->getDriverEscaper()->reserved('D') . '.' + . $this->getDriverEscaper()->reserved('subject') . ' = ' + . $this->getDriverEscaper()->reserved('R') . '.' + . $this->getDriverEscaper()->reserved('object') . ')'; if ($this->getRandom()) { $query = $this->getDriverEscaper()->dbCommand('SELECT') . ' ' . @@ -345,11 +379,12 @@ protected function createMetaQuery($main, $join, $count) $query = $this->sortedQuery($main, $join); } if ($count) { - $query = $this->getDriverEscaper()->dbCommand('SELECT') . ' ' . - $this->getDriverEscaper()->dbCommand('COUNT') . - '( ' . $this->getDriverEscaper()->reserved('subject') . ' ) ' . - $this->getDriverEscaper()->dbCommand('AS') . ' ' . $this->getDriverEscaper()->reserved('cpt') . ' ' . - $this->getDriverEscaper()->dbCommand('FROM') . ' ( ' . $query . ' ) as cptQ'; + $query = $this->getDriverEscaper()->dbCommand('SELECT') . ' ' + . $this->getDriverEscaper()->dbCommand('COUNT') . '( ' + . $this->getDriverEscaper()->reserved('subject') . ' ) ' + . $this->getDriverEscaper()->dbCommand('AS') . ' ' + . $this->getDriverEscaper()->reserved('cpt') . ' ' + . $this->getDriverEscaper()->dbCommand('FROM') . ' ( ' . $query . ' ) as cptQ'; return $query; } return $this->addLimit($query); diff --git a/core/kernel/persistence/wrapper/RdfWrapper.php b/core/kernel/persistence/wrapper/RdfWrapper.php index c6e2a04dd..77ab39ca0 100644 --- a/core/kernel/persistence/wrapper/RdfWrapper.php +++ b/core/kernel/persistence/wrapper/RdfWrapper.php @@ -88,9 +88,18 @@ public function add(\core_kernel_classes_Triple $triple) $resource = new \core_kernel_classes_Resource($triple->subject); $property = new \core_kernel_classes_Property($triple->predicate); if (empty($triple->lg)) { - return $this->rdfsInterface->getResourceImplementation()->setPropertyValue($resource, $property, $triple->object); + return $this->rdfsInterface->getResourceImplementation()->setPropertyValue( + $resource, + $property, + $triple->object + ); } else { - return $this->rdfsInterface->getResourceImplementation()->setPropertyValueByLg($resource, $property, $triple->object, $triple->lg); + return $this->rdfsInterface->getResourceImplementation()->setPropertyValueByLg( + $resource, + $property, + $triple->object, + $triple->lg + ); } } } diff --git a/core/kernel/rules/class.Expression.php b/core/kernel/rules/class.Expression.php index 94fe3d064..c20060b70 100644 --- a/core/kernel/rules/class.Expression.php +++ b/core/kernel/rules/class.Expression.php @@ -15,7 +15,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright (c) 2007-2010 (original work) Public Research Centre Henri Tudor & University of Luxembourg) (under the project TAO-QUAL); + * Copyright (c) 2007-2010 (original work) Public Research Centre Henri Tudor & University of Luxembourg + * (under the project TAO-QUAL); * 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung * (under the project TAO-TRANSFER); * 2017 (update and modification) Open Assessment Technologies SA (under the project TAO-PRODUCT); @@ -155,7 +156,9 @@ public function getFirstExpression() $returnValue = null; if (empty($this->firstExpression)) { $property = new core_kernel_classes_Property(RulesRdf::PROPERTY_FIRST_EXPRESSION); - $this->firstExpression = new core_kernel_rules_Expression($this->getUniquePropertyValue($property)->getUri()); + $this->firstExpression = new core_kernel_rules_Expression( + $this->getUniquePropertyValue($property)->getUri() + ); } $returnValue = $this->firstExpression; return $returnValue; @@ -173,7 +176,9 @@ public function getSecondExpression() $returnValue = null; if (empty($this->secondExpression)) { $property = new core_kernel_classes_Property(RulesRdf::PROPERTY_SECOND_EXPRESSION); - $this->secondExpression = new core_kernel_rules_Expression($this->getUniquePropertyValue($property)->getUri()); + $this->secondExpression = new core_kernel_rules_Expression( + $this->getUniquePropertyValue($property)->getUri() + ); } $returnValue = $this->secondExpression; return $returnValue; @@ -246,7 +251,10 @@ public function expEval($variable = []) ) { $tempResult = false; foreach ($firstPart->getIterator() as $container) { - common_Logger::d('FirstPart Part is ContainerCollection Second is Container', ['Generis Expression']); + common_Logger::d( + 'FirstPart Part is ContainerCollection Second is Container', + ['Generis Expression'] + ); //TODO For now consider that if only one value of the table return true, //TODO exist unique need to be added @@ -269,7 +277,10 @@ public function expEval($variable = []) && $secondPart instanceof core_kernel_classes_ContainerCollection ) { foreach ($secondPart->getIterator() as $container) { - common_Logger::d('FirstPart Part Container is Second is ContainerCollection', ['Generis Expression']); + common_Logger::d( + 'FirstPart Part Container is Second is ContainerCollection', + ['Generis Expression'] + ); //TODO For now consider that all value of the table need to be equal to return true, , //TODO exist unique need to be added diff --git a/core/kernel/rules/class.ExpressionFactory.php b/core/kernel/rules/class.ExpressionFactory.php index 49880077d..04b84747a 100644 --- a/core/kernel/rules/class.ExpressionFactory.php +++ b/core/kernel/rules/class.ExpressionFactory.php @@ -15,7 +15,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright (c) 2007-2010 (original work) Public Research Centre Henri Tudor & University of Luxembourg) (under the project TAO-QUAL); + * Copyright (c) 2007-2010 (original work) Public Research Centre Henri Tudor & University of Luxembourg + * (under the project TAO-QUAL); * 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung * (under the project TAO-TRANSFER); * 2017 (update and modification) Open Assessment Technologies SA (under the project TAO-PRODUCT); @@ -60,7 +61,10 @@ public static function createTerminalExpression(core_kernel_rules_Term $term) $label = 'Terminal Expression : ' . $term->getLabel(); $comment = 'Terminal Expression : ' . $term->getUri(); $expressionInst = core_kernel_classes_ResourceFactory::create($expressionClass, $label, $comment); - $terminalExpressionProperty = new core_kernel_classes_Property(RulesRdf::PROPERTY_TERMINAL_EXPRESSION, __METHOD__); + $terminalExpressionProperty = new core_kernel_classes_Property( + RulesRdf::PROPERTY_TERMINAL_EXPRESSION, + __METHOD__ + ); $returnValue = new core_kernel_rules_Expression($expressionInst->getUri()); $returnValue->setPropertyValue($terminalExpressionProperty, $term->getUri()); $returnValue->debug = __METHOD__; @@ -77,8 +81,11 @@ public static function createTerminalExpression(core_kernel_rules_Term $term) * @param Resource operator * @return core_kernel_rules_Expression */ - public static function createRecursiveExpression(core_kernel_rules_Expression $exp1, core_kernel_rules_Expression $exp2, core_kernel_classes_Resource $operator) - { + public static function createRecursiveExpression( + core_kernel_rules_Expression $exp1, + core_kernel_rules_Expression $exp2, + core_kernel_classes_Resource $operator + ) { $returnValue = null; if ($exp1 == null || $exp2 == null || $operator == null) { var_dump($exp1, $exp2, $operator); @@ -89,7 +96,10 @@ public static function createRecursiveExpression(core_kernel_rules_Expression $e $label = 'Expression : ' . $exp1->getLabel() . ' ' . $operator->getLabel() . ' ' . $exp2->getLabel(); $comment = 'Expression : ' . $exp1->getUri() . ' ' . $operator->getUri() . ' ' . $exp2->getUri(); $expressionInst = core_kernel_classes_ResourceFactory::create($expressionClass, $label, $comment); - $terminalExpressionProperty = new core_kernel_classes_Property(RulesRdf::PROPERTY_TERMINAL_EXPRESSION, __METHOD__); + $terminalExpressionProperty = new core_kernel_classes_Property( + RulesRdf::PROPERTY_TERMINAL_EXPRESSION, + __METHOD__ + ); $logicalOperatorProperty = new core_kernel_classes_Property(RulesRdf::PROPERTY_HASLOGICALOPERATOR, __METHOD__); $firstExpressionProperty = new core_kernel_classes_Property(RulesRdf::PROPERTY_FIRST_EXPRESSION, __METHOD__); $secondExpressionProperty = new core_kernel_classes_Property(RulesRdf::PROPERTY_SECOND_EXPRESSION, __METHOD__); diff --git a/core/kernel/rules/class.Operation.php b/core/kernel/rules/class.Operation.php index 31a504df5..074e5372f 100644 --- a/core/kernel/rules/class.Operation.php +++ b/core/kernel/rules/class.Operation.php @@ -15,7 +15,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright (c) 2007-2010 (original work) Public Research Centre Henri Tudor & University of Luxembourg) (under the project TAO-QUAL); + * Copyright (c) 2007-2010 (original work) Public Research Centre Henri Tudor & University of Luxembourg + * (under the project TAO-QUAL); * 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung * (under the project TAO-TRANSFER); * 2017 (update and modification) Open Assessment Technologies SA (under the project TAO-PRODUCT) @@ -188,8 +189,11 @@ public function evaluate($variable = []) * @param Resource operator * @return mixed */ - public function evaluateRecursiveOperation(core_kernel_classes_Literal $first, core_kernel_classes_Literal $second, core_kernel_classes_Resource $operator) - { + public function evaluateRecursiveOperation( + core_kernel_classes_Literal $first, + core_kernel_classes_Literal $second, + core_kernel_classes_Resource $operator + ) { switch ($operator->getUri()) { diff --git a/core/kernel/rules/class.OperationFactory.php b/core/kernel/rules/class.OperationFactory.php index 69f4a8c95..54d666fc2 100644 --- a/core/kernel/rules/class.OperationFactory.php +++ b/core/kernel/rules/class.OperationFactory.php @@ -15,7 +15,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright (c) 2007-2010 (original work) Public Research Centre Henri Tudor & University of Luxembourg) (under the project TAO-QUAL); + * Copyright (c) 2007-2010 (original work) Public Research Centre Henri Tudor & University of Luxembourg + * (under the project TAO-QUAL); * 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung * (under the project TAO-TRANSFER); * 2017 (update and modification) Open Assessment Technologies SA (under the project TAO-PRODUCT); @@ -52,8 +53,11 @@ class core_kernel_rules_OperationFactory * @param Resource operator * @return core_kernel_rules_Operation */ - public static function createOperation(core_kernel_rules_Term $term1, core_kernel_rules_Term $term2, core_kernel_classes_Resource $operator) - { + public static function createOperation( + core_kernel_rules_Term $term1, + core_kernel_rules_Term $term2, + core_kernel_classes_Resource $operator + ) { $returnValue = null; $operationClass = new core_kernel_classes_Class(RulesRdf::CLASS_OPERATION, __METHOD__); $label = 'Def Operation Label ' . $term1->getLabel() . ' ' . $operator->getLabel() . ' ' . $term2->getLabel(); diff --git a/core/kernel/rules/class.Rule.php b/core/kernel/rules/class.Rule.php index 34285aeb3..131b90366 100644 --- a/core/kernel/rules/class.Rule.php +++ b/core/kernel/rules/class.Rule.php @@ -15,7 +15,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright (c) 2007-2010 (original work) Public Research Centre Henri Tudor & University of Luxembourg) (under the project TAO-QUAL); + * Copyright (c) 2007-2010 (original work) Public Research Centre Henri Tudor & University of Luxembourg + * (under the project TAO-QUAL); * 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung * (under the project TAO-TRANSFER); * 2017 (update and modification) Open Assessment Technologies SA (under the project TAO-PRODUCT); @@ -60,7 +61,10 @@ public function getExpression() common_Logger::i('Evaluating rule ' . $this->getLabel() . '(' . $this->getUri() . ')', ['Generis Rule']); if (empty($this->expression)) { $property = new core_kernel_classes_Property(RulesRdf::PROPERTY_RULE_IF); - $this->expression = new core_kernel_rules_Expression($this->getUniquePropertyValue($property)->getUri(), __METHOD__); + $this->expression = new core_kernel_rules_Expression( + $this->getUniquePropertyValue($property)->getUri(), + __METHOD__ + ); } $returnValue = $this->expression; return $returnValue; diff --git a/core/kernel/rules/class.Term.php b/core/kernel/rules/class.Term.php index 772a41cb7..3837ca938 100644 --- a/core/kernel/rules/class.Term.php +++ b/core/kernel/rules/class.Term.php @@ -15,7 +15,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright (c) 2007-2010 (original work) Public Research Centre Henri Tudor & University of Luxembourg) (under the project TAO-QUAL); + * Copyright (c) 2007-2010 (original work) Public Research Centre Henri Tudor & University of Luxembourg + * (under the project TAO-QUAL); * 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung * (under the project TAO-TRANSFER); * 2017 (update and modification) Open Assessment Technologies SA (under the project TAO-PRODUCT); @@ -106,8 +107,11 @@ public function evaluate($variable = []) * @param ContainerCollection $newSet * @return core_kernel_classes_ContainerCollection */ - public function evalutateSetOperation(core_kernel_classes_Resource $setOperator, common_Collection $actualSet, core_kernel_classes_ContainerCollection $newSet) - { + public function evalutateSetOperation( + core_kernel_classes_Resource $setOperator, + common_Collection $actualSet, + core_kernel_classes_ContainerCollection $newSet + ) { $returnValue = null; if ($setOperator->getUri() == RulesRdf::INSTANCE_OPERATOR_UNION) { $returnValue = $actualSet->union($newSet); @@ -144,19 +148,15 @@ protected function evaluateSPX($variable = []) } try { - $propertyInstance = $this->getUniquePropertyValue(new core_kernel_classes_Property(RulesRdf::PROPERTY_TERM_SPX_PREDICATE)); + $propertyInstance = $this->getUniquePropertyValue( + new core_kernel_classes_Property(RulesRdf::PROPERTY_TERM_SPX_PREDICATE) + ); } catch (common_Exception $e) { echo $e; var_dump($this); die('unable to get property value in Term'); } - // if(array_key_exists($propertyInstance->getUri(),$variable)) { - // $logger->debug('Variable uri : ' . $propertyInstance->getUri() . ' found' , __FILE__, __LINE__); - // $logger->debug('Variable name : ' . $propertyInstance->getLabel() . ' found' , __FILE__, __LINE__); - // $propertyInstance = new core_kernel_classes_Resource($variable[$resource->getUri()]); - // $logger->debug('Variable repaced uri : ' . $propertyInstance->getUri() , __FILE__, __LINE__); - // $logger->debug('Variable repaced name : ' . $propertyInstance->getLabel() , __FILE__, __LINE__); - // } + $property = new core_kernel_classes_Property($propertyInstance->getUri()); common_Logger::d('Property uri ' . $property->getUri(), ['Generis Term evaluateSPX']); common_Logger::d('Property name ' . $property->getLabel(), ['Generis Term evaluateSPX']); diff --git a/core/kernel/rules/class.TermFactory.php b/core/kernel/rules/class.TermFactory.php index 4a3602889..582c4d4e0 100644 --- a/core/kernel/rules/class.TermFactory.php +++ b/core/kernel/rules/class.TermFactory.php @@ -15,7 +15,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright (c) 2007-2010 (original work) Public Research Centre Henri Tudor & University of Luxembourg) (under the project TAO-QUAL); + * Copyright (c) 2007-2010 (original work) Public Research Centre Henri Tudor & University of Luxembourg + * (under the project TAO-QUAL); * 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung * (under the project TAO-TRANSFER); * 2017 (update and modification) Open Assessment Technologies SA (under the project TAO-PRODUCT); @@ -54,7 +55,10 @@ public static function createConst($constant) $termConstClass = new core_kernel_classes_Class(RulesRdf::CLASS_TERM_CONST, __METHOD__); $termValueProperty = new core_kernel_classes_Property(RulesRdf::PROPERTY_TERM_VALUE, __METHOD__); $logicalOperatorProperty = new core_kernel_classes_Property(RulesRdf::PROPERTY_HASLOGICALOPERATOR, __METHOD__); - $terminalExpressionProperty = new core_kernel_classes_Property(RulesRdf::PROPERTY_TERMINAL_EXPRESSION, __METHOD__); + $terminalExpressionProperty = new core_kernel_classes_Property( + RulesRdf::PROPERTY_TERMINAL_EXPRESSION, + __METHOD__ + ); $label = 'Def Term Constant Label : ' . $constant; $comment = 'Def Term Constant Comment : ' . $constant; $constantResource = core_kernel_classes_ResourceFactory::create($termConstClass, $label, $comment); diff --git a/core/kernel/uri/Bin2HexUriProvider.php b/core/kernel/uri/Bin2HexUriProvider.php index ce8300ec4..c41bf13ef 100644 --- a/core/kernel/uri/Bin2HexUriProvider.php +++ b/core/kernel/uri/Bin2HexUriProvider.php @@ -49,6 +49,7 @@ class Bin2HexUriProvider extends ConfigurableService implements UriProvider */ public function provide() { - return $this->getOption(self::OPTION_NAMESPACE) . uniqid('i') . getmypid() . bin2hex(openssl_random_pseudo_bytes(8)); + return $this->getOption(self::OPTION_NAMESPACE) . uniqid('i') . getmypid() + . bin2hex(openssl_random_pseudo_bytes(8)); } } diff --git a/core/kernel/uri/MicrotimeRandUriProvider.php b/core/kernel/uri/MicrotimeRandUriProvider.php index 60fb94b19..597875407 100644 --- a/core/kernel/uri/MicrotimeRandUriProvider.php +++ b/core/kernel/uri/MicrotimeRandUriProvider.php @@ -54,7 +54,10 @@ class MicrotimeRandUriProvider extends ConfigurableService implements UriProvide */ public function getPersistence() { - return $this->getServiceLocator()->get(PersistenceManager::SERVICE_ID)->getPersistenceById($this->getOption(self::OPTION_PERSISTENCE)); + return $this + ->getServiceLocator() + ->get(PersistenceManager::SERVICE_ID) + ->getPersistenceById($this->getOption(self::OPTION_PERSISTENCE)); } /** @@ -70,8 +73,11 @@ public function provide() $uriExist = false; do { list($usec, $sec) = explode(" ", microtime()); - $uri = $this->getOption(self::OPTION_NAMESPACE) . 'i' . (str_replace(".", "", $sec . "" . $usec)) . rand(0, 1000); - $sqlResult = $this->getPersistence()->query("SELECT COUNT(subject) AS num FROM statements WHERE subject = '" . $uri . "'"); + $uri = $this->getOption(self::OPTION_NAMESPACE) . 'i' . (str_replace(".", "", $sec + . "" . $usec)) . rand(0, 1000); + $sqlResult = $this->getPersistence()->query( + "SELECT COUNT(subject) AS num FROM statements WHERE subject = '" . $uri . "'" + ); if ($row = $sqlResult->fetch()) { $uriExist = $row['num'] > 0; $sqlResult->closeCursor(); diff --git a/core/kernel/uri/class.DatabaseSerialUriProvider.php b/core/kernel/uri/class.DatabaseSerialUriProvider.php index cd2d25c3f..6d0336052 100644 --- a/core/kernel/uri/class.DatabaseSerialUriProvider.php +++ b/core/kernel/uri/class.DatabaseSerialUriProvider.php @@ -66,9 +66,10 @@ public function provide() { $returnValue = (string) ''; try { - $sth = $this->getPersistence()->query($this->getPersistence()->getPlatForm()->getSqlFunction("generis_sequence_uri_provider"), [ - $this->getOption(self::OPTION_NAMESPACE) - ]); + $sth = $this->getPersistence()->query( + $this->getPersistence()->getPlatForm()->getSqlFunction("generis_sequence_uri_provider"), + [$this->getOption(self::OPTION_NAMESPACE)] + ); if ($sth !== false) { $row = $sth->fetch(); @@ -76,7 +77,10 @@ public function provide() $returnValue = current($row); $sth->closeCursor(); } else { - throw new UriProviderException("An error occured while calling the stored procedure for persistence " . $this->getOption(self::OPTION_PERSISTENCE) . "."); + throw new UriProviderException( + "An error occured while calling the stored procedure for persistence " + . $this->getOption(self::OPTION_PERSISTENCE) . "." + ); } } catch (Exception $e) { throw new UriProviderException("An error occured while calling the stored ': " . $e->getMessage() . "."); diff --git a/core/kernel/users/class.AuthAdapter.php b/core/kernel/users/class.AuthAdapter.php index 74cc71075..23f5e693f 100755 --- a/core/kernel/users/class.AuthAdapter.php +++ b/core/kernel/users/class.AuthAdapter.php @@ -84,7 +84,9 @@ public function authenticate() if (count($users) > 1) { // Multiple users matching - throw new common_exception_InconsistentData("Multiple Users found with the same login '" . $this->username . "'."); + throw new common_exception_InconsistentData( + "Multiple Users found with the same login '" . $this->username . "'." + ); } if (empty($users)) { // fake code execution to prevent timing attacks @@ -98,7 +100,9 @@ public function authenticate() } $userResource = current($users); - $hash = $userResource->getUniquePropertyValue(new core_kernel_classes_Property(GenerisRdf::PROPERTY_USER_PASSWORD)); + $hash = $userResource->getUniquePropertyValue( + new core_kernel_classes_Property(GenerisRdf::PROPERTY_USER_PASSWORD) + ); if (!core_kernel_users_Service::getPasswordHash()->verify($this->password, $hash)) { throw new core_kernel_users_InvalidLoginException(); } diff --git a/core/kernel/users/class.Cache.php b/core/kernel/users/class.Cache.php index 9b9470f7d..837416422 100644 --- a/core/kernel/users/class.Cache.php +++ b/core/kernel/users/class.Cache.php @@ -148,7 +148,8 @@ public static function removeIncludedRoles(core_kernel_classes_Resource $role) * * @access public * @author Jerome Bogaerts, - * @param core_kernel_classes_Resource $role The Generis Role you want to check if its included roles are in the cache memory. + * @param core_kernel_classes_Resource $role The Generis Role you want to check if its included roles are in the + * cache memory. * @return boolean */ public static function areIncludedRolesInCache(core_kernel_classes_Resource $role) diff --git a/core/kernel/users/class.Service.php b/core/kernel/users/class.Service.php index cf6bff0b2..ae4fc4f9a 100644 --- a/core/kernel/users/class.Service.php +++ b/core/kernel/users/class.Service.php @@ -104,12 +104,19 @@ public function loginExists($login, core_kernel_classes_Class $class = null) * @param Resource role A Role to grant to the new User. * @return core_kernel_classes_Resource */ - public function addUser($login, $password, core_kernel_classes_Resource $role = null, core_kernel_classes_Class $class = null) - { + public function addUser( + $login, + $password, + core_kernel_classes_Resource $role = null, + core_kernel_classes_Class $class = null + ) { $returnValue = null; if ($this->loginExists($login)) { - throw new core_kernel_users_Exception("Login '${login}' already in use.", core_kernel_users_Exception::LOGIN_EXITS); + throw new core_kernel_users_Exception( + "Login '${login}' already in use.", + core_kernel_users_Exception::LOGIN_EXITS + ); } else { $role = (empty($role)) ? new core_kernel_classes_Resource(GenerisRdf::INSTANCE_ROLE_GENERIS) : $role; @@ -227,10 +234,15 @@ public function isPasswordValid($password, core_kernel_classes_Resource $user) public function setPassword(core_kernel_classes_Resource $user, $password) { if (!is_string($password)) { - throw new core_kernel_users_Exception('The password must be of "string" type, got ' . gettype($password)); + throw new core_kernel_users_Exception( + 'The password must be of "string" type, got ' . gettype($password) + ); } - $user->editPropertyValues(new core_kernel_classes_Property(GenerisRdf::PROPERTY_USER_PASSWORD), core_kernel_users_Service::getPasswordHash()->encrypt($password)); + $user->editPropertyValues( + new core_kernel_classes_Property(GenerisRdf::PROPERTY_USER_PASSWORD), + core_kernel_users_Service::getPasswordHash()->encrypt($password) + ); } /** @@ -291,7 +303,9 @@ public function userHasRoles(core_kernel_classes_Resource $user, $roles) } } else { // After introducing remote users, we can no longer guarantee that any user and his roles are available - common_Logger::w('Roles of non current user (' . $user->getUri() . ') checked, trying fallback to local ontology'); + common_Logger::w( + 'Roles of non current user (' . $user->getUri() . ') checked, trying fallback to local ontology' + ); $userRoles = array_keys($this->getUserRoles($user)); $identicalRoles = array_intersect($searchRoles, $userRoles); @@ -354,8 +368,9 @@ public function unnatachRole(core_kernel_classes_Resource $user, core_kernel_cla * * @access public * @author Jerome Bogaerts, - * @param string label The label to apply to the newly created Generis Role. - * @param includedRoles The Role(s) to be included in the newly created Generis Role. Can be either a Resource or an array of Resources. + * @param string $label The label to apply to the newly created Generis Role. + * @param $includedRoles The Role(s) to be included in the newly created Generis Role. Can be either a Resource or + * an array of Resources. * @return core_kernel_classes_Resource */ public function addRole($label, $includedRoles = null, core_kernel_classes_Class $class = null) @@ -422,7 +437,8 @@ public function removeRole(core_kernel_classes_Resource $role) * * @param core_kernel_classes_Resource $role A Generis Role. * - * @return array An associative array where keys are Role URIs and values are instances of core_kernel_classes_Resource. + * @return array An associative array where keys are Role URIs and values are instances of + * core_kernel_classes_Resource. * @throws core_kernel_users_CacheException * @throws core_kernel_users_Exception */ @@ -566,9 +582,10 @@ public function unincludeRole(core_kernel_classes_Resource $role, core_kernel_cl * * @access public * @author Jerome Bogaerts, - * @param string login The login of the user. - * @param string password the md5 hash of the password. - * @param allowedRoles A Role or an array of Roles that are allowed to be logged in. If the user has a Role that matches one or more Roles in this array, the login request will be accepted. + * @param string $login The login of the user. + * @param string $password the md5 hash of the password. + * @param $allowedRoles - A role or an array of Roles that are allowed to be logged in. If the user has a Role that + * matches one or more Roles in this array, the login request will be accepted. * @return boolean */ public function login($login, $password, $allowedRoles) @@ -622,7 +639,8 @@ public function logout() /** * Returns the whole collection of Roles in Generis. * - * @return array An associative array where keys are Role URIs and values are instances of the core_kernel_classes_Resource PHP class. + * @return array An associative array where keys are Role URIs and values are instances of the + * core_kernel_classes_Resource PHP class. */ public function getAllRoles() { diff --git a/core/kernel/users/interface.RolesManagement.php b/core/kernel/users/interface.RolesManagement.php index c76defad8..3d7a91b04 100644 --- a/core/kernel/users/interface.RolesManagement.php +++ b/core/kernel/users/interface.RolesManagement.php @@ -39,8 +39,9 @@ interface core_kernel_users_RolesManagement * * @access public * @author Jerome Bogaerts, - * @param string label The label to apply to the newly created Generis Role. - * @param includedRoles The Role(s) to be included in the newly created Generis Role. Can be either a Resource or an array of Resources. + * @param string $label The label to apply to the newly created Generis Role. + * @param $includedRoles The Role(s) to be included in the newly created Generis Role. Can be either a Resource or + * an array of Resources. * @return core_kernel_classes_Resource */ public function addRole($label, $includedRoles = null, core_kernel_classes_Class $class = null); @@ -90,7 +91,8 @@ public function unincludeRole(core_kernel_classes_Resource $role, core_kernel_cl * * @access public * @author Jerome Bogaerts - * @return array An associative array where keys are Role URIs and values are instances of the core_kernel_classes_Resource class. + * @return array An associative array where keys are Role URIs and values are instances of the + * core_kernel_classes_Resource class. */ public function getAllRoles(); } diff --git a/core/user/AuthAdapter.php b/core/user/AuthAdapter.php index 3542fd954..c5ea230ca 100644 --- a/core/user/AuthAdapter.php +++ b/core/user/AuthAdapter.php @@ -91,7 +91,9 @@ public function authenticate() if ($this->hasOption(self::OPTION_PATTERN)) { if (preg_match($this->getOption(self::OPTION_PATTERN), $this->username) === 0) { - throw new core_kernel_users_InvalidLoginException("Invalid pattern for user '" . $this->username . "'."); + throw new core_kernel_users_InvalidLoginException( + "Invalid pattern for user '" . $this->username . "'." + ); } } @@ -103,7 +105,9 @@ public function authenticate() if (count($users) > 1) { // Multiple users matching - throw new common_exception_InconsistentData("Multiple Users found with the same login '" . $this->username . "'."); + throw new common_exception_InconsistentData( + "Multiple Users found with the same login '" . $this->username . "'." + ); } if (empty($users)) { // fake code execution to prevent timing attacks @@ -113,11 +117,15 @@ public function authenticate() throw new core_kernel_users_InvalidLoginException('Unknown user "' . $this->username . '"'); } // should never happen, added for integrity - throw new core_kernel_users_InvalidLoginException('Inexisting user did not fail password check, this should not happen'); + throw new core_kernel_users_InvalidLoginException( + 'Inexisting user did not fail password check, this should not happen' + ); } $userResource = current($users); - $hash = $userResource->getUniquePropertyValue(new core_kernel_classes_Property(GenerisRdf::PROPERTY_USER_PASSWORD)); + $hash = $userResource->getUniquePropertyValue( + new core_kernel_classes_Property(GenerisRdf::PROPERTY_USER_PASSWORD) + ); if (!core_kernel_users_Service::getPasswordHash()->verify($this->password, $hash)) { throw new core_kernel_users_InvalidLoginException('Invalid password for user "' . $this->username . '"'); } diff --git a/test/GenerisPhpUnitTestRunner.php b/test/GenerisPhpUnitTestRunner.php index 85afc3a42..f9fc25106 100755 --- a/test/GenerisPhpUnitTestRunner.php +++ b/test/GenerisPhpUnitTestRunner.php @@ -173,7 +173,9 @@ protected function restoreCache() public static function getTestSession() { if (!self::$connected) { - throw new common_exception_Error('Trying to retrieve TestSession without initialising it first via initTest()'); + throw new common_exception_Error( + 'Trying to retrieve TestSession without initialising it first via initTest()' + ); } $session = common_session_SessionManager::getSession(); if (!$session instanceof common_test_TestUserSession) { diff --git a/test/OntologyMockTrait.php b/test/OntologyMockTrait.php index 30eaceb1b..d6414d8a5 100644 --- a/test/OntologyMockTrait.php +++ b/test/OntologyMockTrait.php @@ -87,7 +87,9 @@ private function setupOntology(Ontology $onto) SessionService::SERVICE_ID => $this->getSessionServiceMock($session), EventManager::SERVICE_ID => $eventManager, LoggerService::SERVICE_ID => $this->prophesize(LoggerInterface::class)->reveal(), - UriProvider::SERVICE_ID => new Bin2HexUriProvider([Bin2HexUriProvider::OPTION_NAMESPACE => 'http://ontology.mock/bin2hex#']), + UriProvider::SERVICE_ID => new Bin2HexUriProvider([ + Bin2HexUriProvider::OPTION_NAMESPACE => 'http://ontology.mock/bin2hex#' + ]), SimpleCache::SERVICE_ID => new NoCache(), DriverConfigurationFeeder::SERVICE_ID => new DriverConfigurationFeeder(), EventAggregator::SERVICE_ID => $eventAggregator diff --git a/test/integration/ClassTest.php b/test/integration/ClassTest.php index b82b1b3e8..8ce1d18db 100755 --- a/test/integration/ClassTest.php +++ b/test/integration/ClassTest.php @@ -374,13 +374,31 @@ public function testGetInstancesPropertyValuesWithLiteralProperties() $class = new core_kernel_classes_Class(GenerisRdf::CLASS_GENERIS_RESOURCE); $subClass = $class->createSubClass('GetInstancesPropertyValuesClass', 'GetInstancesPropertyValues_Class'); // create a first property for this class - $p1 = core_kernel_classes_ClassFactory::createProperty($subClass, 'GetInstancesPropertyValues_Property1', 'GetInstancesPropertyValues_Property1', false, LOCAL_NAMESPACE . "#P1"); + $p1 = core_kernel_classes_ClassFactory::createProperty( + $subClass, + 'GetInstancesPropertyValues_Property1', + 'GetInstancesPropertyValues_Property1', + false, + LOCAL_NAMESPACE . "#P1" + ); $p1->setRange(new core_kernel_classes_Class(OntologyRdfs::RDFS_LITERAL)); // create a second property for this class - $p2 = core_kernel_classes_ClassFactory::createProperty($subClass, 'GetInstancesPropertyValues_Property2', 'GetInstancesPropertyValues_Property2', false, LOCAL_NAMESPACE . "#P2"); + $p2 = core_kernel_classes_ClassFactory::createProperty( + $subClass, + 'GetInstancesPropertyValues_Property2', + 'GetInstancesPropertyValues_Property2', + false, + LOCAL_NAMESPACE . "#P2" + ); $p2->setRange(new core_kernel_classes_Class(OntologyRdfs::RDFS_LITERAL)); // create a second property for this class - $p3 = core_kernel_classes_ClassFactory::createProperty($subClass, 'GetInstancesPropertyValues_Property3', 'GetInstancesPropertyValues_Property3', false, LOCAL_NAMESPACE . "#P3"); + $p3 = core_kernel_classes_ClassFactory::createProperty( + $subClass, + 'GetInstancesPropertyValues_Property3', + 'GetInstancesPropertyValues_Property3', + false, + LOCAL_NAMESPACE . "#P3" + ); $p2->setRange(new core_kernel_classes_Class(OntologyRdfs::RDFS_LITERAL)); // $i1 $i1 = $subClass->createInstance("i1", "i1"); @@ -488,13 +506,31 @@ public function testGetInstancesPropertyValuesWithResourceProperties() $class = new core_kernel_classes_Class(GenerisRdf::CLASS_GENERIS_RESOURCE); $subClass = $class->createSubClass('GetInstancesPropertyValuesClass', 'GetInstancesPropertyValues_Class'); // create a first property for this class - $p1 = core_kernel_classes_ClassFactory::createProperty($subClass, 'GetInstancesPropertyValues_Property1', 'GetInstancesPropertyValues_Property1', false, LOCAL_NAMESPACE . "#P1"); + $p1 = core_kernel_classes_ClassFactory::createProperty( + $subClass, + 'GetInstancesPropertyValues_Property1', + 'GetInstancesPropertyValues_Property1', + false, + LOCAL_NAMESPACE . "#P1" + ); $p1->setRange(new core_kernel_classes_Class(GenerisRdf::GENERIS_BOOLEAN)); // create a second property for this class - $p2 = core_kernel_classes_ClassFactory::createProperty($subClass, 'GetInstancesPropertyValues_Property2', 'GetInstancesPropertyValues_Property2', false, LOCAL_NAMESPACE . "#P2"); + $p2 = core_kernel_classes_ClassFactory::createProperty( + $subClass, + 'GetInstancesPropertyValues_Property2', + 'GetInstancesPropertyValues_Property2', + false, + LOCAL_NAMESPACE . "#P2" + ); $p1->setRange(new core_kernel_classes_Class(GenerisRdf::GENERIS_BOOLEAN)); // create a second property for this class - $p3 = core_kernel_classes_ClassFactory::createProperty($subClass, 'GetInstancesPropertyValues_Property3', 'GetInstancesPropertyValues_Property3', false, LOCAL_NAMESPACE . "#P3"); + $p3 = core_kernel_classes_ClassFactory::createProperty( + $subClass, + 'GetInstancesPropertyValues_Property3', + 'GetInstancesPropertyValues_Property3', + false, + LOCAL_NAMESPACE . "#P3" + ); $p1->setRange(new core_kernel_classes_Class(OntologyRdfs::RDFS_LITERAL)); // $i1 $i1 = $subClass->createInstance("i1", "i1"); @@ -536,7 +572,9 @@ public function testGetInstancesPropertyValuesWithResourceProperties() $result = $subClass->getInstancesPropertyValues($p2, $propertyFilters, ["distinct" => true]); $this->assertEquals(count($result), 2); foreach ($result as $property) { - $this->assertTrue($property->getUri() == GenerisRdf::GENERIS_TRUE || $property->getUri() == GenerisRdf::GENERIS_FALSE); + $this->assertTrue( + $property->getUri() == GenerisRdf::GENERIS_TRUE || $property->getUri() == GenerisRdf::GENERIS_FALSE + ); } // Search * P2 for P1=NotExistingProperty litteral WITH DISTINCT options @@ -584,7 +622,9 @@ public function testGetInstancesPropertyValuesWithResourceProperties() $result = $subClass->getInstancesPropertyValues($p2, $propertyFilters, ["distinct" => true]); $this->assertEquals(count($result), 2); foreach ($result as $property) { - $this->assertTrue($property->getUri() == GenerisRdf::GENERIS_TRUE || $property->getUri() == GenerisRdf::GENERIS_FALSE); + $this->assertTrue( + $property->getUri() == GenerisRdf::GENERIS_TRUE || $property->getUri() == GenerisRdf::GENERIS_FALSE + ); } // Clean the model diff --git a/test/integration/ComplexSearchTest.php b/test/integration/ComplexSearchTest.php index 5e8ae8384..5b6f6004b 100644 --- a/test/integration/ComplexSearchTest.php +++ b/test/integration/ComplexSearchTest.php @@ -34,7 +34,9 @@ protected function setUp(): void $this->object = new core_kernel_classes_Class(OntologyRdfs::RDFS_RESOURCE); $this->object->debug = __METHOD__; - $this->search = ServiceManager::getServiceManager()->get(\oat\generis\model\kernel\persistence\smoothsql\search\ComplexSearchService::SERVICE_ID); + $this->search = ServiceManager::getServiceManager()->get( + \oat\generis\model\kernel\persistence\smoothsql\search\ComplexSearchService::SERVICE_ID + ); } public function testRandomized() diff --git a/test/integration/CreateInstanceTest.php b/test/integration/CreateInstanceTest.php index ae4331909..69fe818e4 100755 --- a/test/integration/CreateInstanceTest.php +++ b/test/integration/CreateInstanceTest.php @@ -42,7 +42,10 @@ protected function setUp(): void { GenerisPhpUnitTestRunner::initTest(); - $classres = core_kernel_classes_ResourceFactory::create(new core_kernel_classes_Class(OntologyRdfs::RDFS_CLASS), 'TestClass'); + $classres = core_kernel_classes_ResourceFactory::create( + new core_kernel_classes_Class(OntologyRdfs::RDFS_CLASS), + 'TestClass' + ); $this->class = new core_kernel_classes_Class($classres->getUri()); $this->assertIsA($this->class, 'core_kernel_classes_Class'); $this->assertTrue($this->class->hasType(new core_kernel_classes_Class(OntologyRdfs::RDFS_CLASS))); @@ -80,9 +83,17 @@ public function testCreateInstanceWithProperties() // simple case, without params - $class = $this->class; - $litproperty = new core_kernel_classes_Property(core_kernel_classes_ResourceFactory::create(new core_kernel_classes_Class(OntologyRdf::RDF_PROPERTY))->getUri()); - $property = new core_kernel_classes_Property(core_kernel_classes_ResourceFactory::create(new core_kernel_classes_Class(OntologyRdf::RDF_PROPERTY))->getUri()); + $class = $this->class; + $litproperty = new core_kernel_classes_Property( + core_kernel_classes_ResourceFactory::create( + new core_kernel_classes_Class(OntologyRdf::RDF_PROPERTY) + )->getUri() + ); + $property = new core_kernel_classes_Property( + core_kernel_classes_ResourceFactory::create( + new core_kernel_classes_Class(OntologyRdf::RDF_PROPERTY) + )->getUri() + ); $instance = $class->createInstanceWithProperties([]); $this->assertTrue($instance->hasType($class)); @@ -137,9 +148,15 @@ public function testCreateInstanceWithProperties() $this->assertEquals($propActual, $propNormative); // multiple classes - $classres = core_kernel_classes_ResourceFactory::create(new core_kernel_classes_Class(OntologyRdfs::RDFS_CLASS), 'TestClass2'); + $classres = core_kernel_classes_ResourceFactory::create( + new core_kernel_classes_Class(OntologyRdfs::RDFS_CLASS), + 'TestClass2' + ); $class2 = new core_kernel_classes_Class($classres); - $classres = core_kernel_classes_ResourceFactory::create(new core_kernel_classes_Class(OntologyRdfs::RDFS_CLASS), 'TestClass3'); + $classres = core_kernel_classes_ResourceFactory::create( + new core_kernel_classes_Class(OntologyRdfs::RDFS_CLASS), + 'TestClass3' + ); $class3 = new core_kernel_classes_Class($classres); // 2 classes (by ressource) diff --git a/test/integration/DbWrapperTest.php b/test/integration/DbWrapperTest.php index b3bd008b4..8178295c8 100755 --- a/test/integration/DbWrapperTest.php +++ b/test/integration/DbWrapperTest.php @@ -44,7 +44,10 @@ protected function setUp(): void "uri" VARCHAR(255) NOT NULL, "coluMn1" VARCHAR(255) )'); for ($i = 0; $i < 4; $i++) { - $dbWrapper->exec('INSERT INTO "dbTestCase" (id,uri,"coluMn1") VALUES (?,?,?) ;', [$i,'http://uri' . $i,'value' . $i]); + $dbWrapper->exec( + 'INSERT INTO "dbTestCase" (id,uri,"coluMn1") VALUES (?,?,?) ;', + [$i,'http://uri' . $i,'value' . $i] + ); } } @@ -69,7 +72,10 @@ public function testGetColumnNames() $possibleValues = ['id','uri','coluMn1']; foreach ($columns as $col) { if ($col instanceof Doctrine\DBAL\Schema\Column) { - $this->assertTrue(in_array($col->getName(), $possibleValues), $col->getName() . ' is not a correct value'); + $this->assertTrue( + in_array($col->getName(), $possibleValues), + $col->getName() . ' is not a correct value' + ); } else { //legacy mode $this->assertTrue(in_array($col, $possibleValues)); @@ -134,7 +140,10 @@ public function testCreateIndex() $indexes = $dbWrapper->getSchemaManager()->getTableIndexes('dbtestcase2'); foreach ($indexes as $index) { - $this->assertTrue(in_array($index->getName(), ['idx_content','dbtestcase2_pkey','PRIMARY']), $index->getName() . 'is missing'); + $this->assertTrue( + in_array($index->getName(), ['idx_content','dbtestcase2_pkey','PRIMARY']), + $index->getName() . 'is missing' + ); } $dbWrapper->exec('DROP TABLE dbtestcase2'); diff --git a/test/integration/RdfExportTest.php b/test/integration/RdfExportTest.php index 1cd25c701..2efb29fcb 100755 --- a/test/integration/RdfExportTest.php +++ b/test/integration/RdfExportTest.php @@ -30,7 +30,10 @@ class RdfExportTest extends GenerisPhpUnitTestRunner public function testFullExport() { $dbWrapper = core_kernel_classes_DbWrapper::singleton(); - $result = $dbWrapper->query('SELECT count(*) as count FROM (SELECT DISTINCT subject, predicate, object, l_language FROM statements) as supercount')->fetch(); + $result = $dbWrapper->query( + 'SELECT count(*) as count FROM (SELECT DISTINCT subject, predicate, object, l_language FROM statements)' + . ' as supercount' + )->fetch(); $triples = $result['count']; diff --git a/test/integration/ResourceTest.php b/test/integration/ResourceTest.php index a5191ca0a..6f8e54512 100755 --- a/test/integration/ResourceTest.php +++ b/test/integration/ResourceTest.php @@ -108,7 +108,9 @@ public function testGetPropertyValuesCollection() foreach ($collection->getIterator() as $value) { $this->assertIsA($value, 'core_kernel_classes_Container'); if ($value instanceof core_kernel_classes_Resource) { - $this->assertTrue($value->getUri() == GenerisRdf::GENERIS_TRUE || $value->getUri() == GenerisRdf::GENERIS_FALSE); + $this->assertTrue( + $value->getUri() == GenerisRdf::GENERIS_TRUE || $value->getUri() == GenerisRdf::GENERIS_FALSE + ); } if ($value instanceof core_kernel_classes_Literal) { $this->assertEquals($value->literal, 'plop'); @@ -123,7 +125,9 @@ public function testGetPropertyValuesCollection() foreach ($collection->getIterator() as $value) { $this->assertIsA($value, 'core_kernel_classes_Container'); if ($value instanceof core_kernel_classes_Resource) { - $this->assertTrue($value->getUri() == GenerisRdf::GENERIS_TRUE || $value->getUri() == GenerisRdf::GENERIS_FALSE); + $this->assertTrue( + $value->getUri() == GenerisRdf::GENERIS_TRUE || $value->getUri() == GenerisRdf::GENERIS_FALSE + ); } if ($value instanceof core_kernel_classes_Literal) { $this->assertEquals($value->literal, 'plop'); @@ -138,10 +142,16 @@ public function testGetPropertyValuesCollection() foreach ($collection->getIterator() as $value) { $this->assertInstanceOf('core_kernel_classes_Container', $value); if ($value instanceof core_kernel_classes_Resource) { - $this->assertTrue($value->getUri() == GenerisRdf::GENERIS_TRUE, $value->getUri() . ' must be equal to ' . GenerisRdf::GENERIS_TRUE); + $this->assertTrue( + $value->getUri() == GenerisRdf::GENERIS_TRUE, + $value->getUri() . ' must be equal to ' . GenerisRdf::GENERIS_TRUE + ); } if ($value instanceof core_kernel_classes_Literal) { - $this->assertTrue($value->literal == 'plup' || $value->literal == 'plip', $value->literal . ' must be equal to plip or plop'); + $this->assertTrue( + $value->literal == 'plup' || $value->literal == 'plip', + $value->literal . ' must be equal to plip or plop' + ); } } @@ -165,7 +175,8 @@ public function testGetPropertiesValues() $resource->setPropertyValue($property2, 'prop2'); $resource->setPropertyValue($property3, 'prop3'); - //test that the get properties values is getting an array as parameter, if the parameter is not an array, the function will return an exception + // test that the get properties values is getting an array as parameter, if the parameter is not an array, the + // function will return an exception try { $resource->getPropertiesValues($property1); $this->assertTrue(false); @@ -289,7 +300,9 @@ public function testSetPropertyValue() foreach ($collection->getIterator() as $value) { $this->assertIsA($value, 'core_kernel_classes_Container'); if ($value instanceof core_kernel_classes_Resource) { - $this->assertTrue($value->getUri() == GenerisRdf::GENERIS_TRUE || $value->getUri() == GenerisRdf::GENERIS_FALSE); + $this->assertTrue( + $value->getUri() == GenerisRdf::GENERIS_TRUE || $value->getUri() == GenerisRdf::GENERIS_FALSE + ); } if ($value instanceof core_kernel_classes_Literal) { $this->assertEquals($value->literal, "&plop n'\"; plop'\' plop"); @@ -368,8 +381,12 @@ public function testGetPropertyValuesByLg() $this->assertTrue($collectionFr->count() == 2); $collectionEn = $instance->getPropertyValuesByLg($seeAlso, 'EN'); $this->assertTrue($collectionEn->count() == 1); - $this->assertTrue($collectionFr->get(0)->literal == 'vrai peut etre' || $collectionFr->get(0)->literal == 'vrai'); - $this->assertTrue($collectionFr->get(1)->literal == 'vrai peut etre' || $collectionFr->get(1)->literal == 'vrai'); + $this->assertTrue( + $collectionFr->get(0)->literal == 'vrai peut etre' || $collectionFr->get(0)->literal == 'vrai' + ); + $this->assertTrue( + $collectionFr->get(1)->literal == 'vrai peut etre' || $collectionFr->get(1)->literal == 'vrai' + ); $this->assertTrue($collectionEn->get(0)->literal == 'true'); $instance->delete(); $seeAlso->delete(); @@ -389,8 +406,12 @@ public function testSetPropertyValueByLg() $this->assertTrue($collectionFr->count() == 2); $collectionEn = $instance->getPropertyValuesByLg($seeAlso, 'EN'); $this->assertTrue($collectionEn->count() == 1); - $this->assertTrue($collectionFr->get(0)->literal == 'vrai peut etre' || $collectionFr->get(0)->literal == 'vrai'); - $this->assertTrue($collectionFr->get(1)->literal == 'vrai peut etre' || $collectionFr->get(1)->literal == 'vrai'); + $this->assertTrue( + $collectionFr->get(0)->literal == 'vrai peut etre' || $collectionFr->get(0)->literal == 'vrai' + ); + $this->assertTrue( + $collectionFr->get(1)->literal == 'vrai peut etre' || $collectionFr->get(1)->literal == 'vrai' + ); $this->assertTrue($collectionEn->get(0)->literal == 'true'); $instance->delete(); $seeAlso->delete(); @@ -733,7 +754,9 @@ public function testIsClass() public function testClone() { $this->expectException(common_exception_DeprecatedApiMethod::class); - $this->expectExceptionMessage('Use duplicated instead, because clone resource could not share same uri that original'); + $this->expectExceptionMessage( + 'Use duplicated instead, because clone resource could not share same uri that original' + ); $class = new core_kernel_classes_Class(GenerisRdf::GENERIS_BOOLEAN, __METHOD__); $instance = $class->createInstance('test', 'test'); $clone = clone $instance; diff --git a/test/integration/SqlInjectionTest.php b/test/integration/SqlInjectionTest.php index 2ef35d0a2..018dedc66 100644 --- a/test/integration/SqlInjectionTest.php +++ b/test/integration/SqlInjectionTest.php @@ -40,7 +40,10 @@ public function testInject() $testInstance->setPropertiesValues([ OntologyRdfs::RDFS_COMMENT => '"hi"' ]); - $this->assertEquals($testInstance->getUniquePropertyValue(new core_kernel_classes_Property(OntologyRdfs::RDFS_LABEL)), "\"hi\""); + $this->assertEquals( + $testInstance->getUniquePropertyValue(new core_kernel_classes_Property(OntologyRdfs::RDFS_LABEL)), + "\"hi\"" + ); } catch (DBALException $e) { $this->fail('SQL Error: ' . $e->getMessage()); } diff --git a/test/integration/UserServiceTest.php b/test/integration/UserServiceTest.php index f4fc2fd84..e005d08b1 100755 --- a/test/integration/UserServiceTest.php +++ b/test/integration/UserServiceTest.php @@ -67,7 +67,11 @@ public static function initRoles() $prefix = LOCAL_NAMESPACE . '#'; // Do not forget that more you go deep in the Roles hierarchy, more rights you have. - $baseRole = $roleClass->createInstance('BASE Role', 'The base role of the hierarchy (minimal rights).', $prefix . 'baseRole'); + $baseRole = $roleClass->createInstance( + 'BASE Role', + 'The base role of the hierarchy (minimal rights).', + $prefix . 'baseRole' + ); $baseRole->setPropertyValue($isSystemProperty, $falseInstance); $subRole1 = $roleClass->createInstance('SUB Role 1', 'Includes BASE role.', $prefix . 'subRole1'); @@ -90,7 +94,11 @@ public static function initRoles() $subRole12->setPropertyValue($includesRoleProperty, $subRole1); $subRole12->setPropertyValue($isSystemProperty, $falseInstance); - $subRole13 = $roleClass->createInstance('SUB Role 13', 'Includes SUB Role 1, SUB Role 11, SUB Role 12.', $prefix . 'subRole13'); + $subRole13 = $roleClass->createInstance( + 'SUB Role 13', + 'Includes SUB Role 1, SUB Role 11, SUB Role 12.', + $prefix . 'subRole13' + ); $subRole13->setPropertyValue($includesRoleProperty, $subRole1); $subRole13->setPropertyValue($includesRoleProperty, $subRole11); $subRole13->setPropertyValue($includesRoleProperty, $subRole12); @@ -463,7 +471,11 @@ public function testRolesCache() // Nothing is in the cache, we should get an exception. try { core_kernel_users_Cache::retrieveIncludedRoles($role); - $this->assertTrue(false, 'An exception should be raised when trying to retrieve included roles that are not yet in the cache memory.'); + $this->assertTrue( + false, + 'An exception should be raised when trying to retrieve included roles that are not yet in the ' + . 'cache memory.' + ); } catch (core_kernel_users_CacheException $e) { $this->assertTrue(true); } diff --git a/test/integration/common/filesystem/DirectoryFilesystemTest.php b/test/integration/common/filesystem/DirectoryFilesystemTest.php index 09b70d49e..5e04b8ddd 100644 --- a/test/integration/common/filesystem/DirectoryFilesystemTest.php +++ b/test/integration/common/filesystem/DirectoryFilesystemTest.php @@ -129,7 +129,9 @@ private function getTempDirectory() private function getMockFileSystem() { if ($this->fileSystemService === null) { - $this->fileSystemService = $this->getServiceLocatorMock([FileSystemService::SERVICE_ID => new FileSystemService()])->get(FileSystemService::SERVICE_ID); + $this->fileSystemService = $this + ->getServiceLocatorMock([FileSystemService::SERVICE_ID => new FileSystemService()]) + ->get(FileSystemService::SERVICE_ID); } return $this->fileSystemService; diff --git a/test/integration/helpers/FileSerializerMigrationHelperTest.php b/test/integration/helpers/FileSerializerMigrationHelperTest.php index c35711e26..1e072c44c 100644 --- a/test/integration/helpers/FileSerializerMigrationHelperTest.php +++ b/test/integration/helpers/FileSerializerMigrationHelperTest.php @@ -156,7 +156,9 @@ private function getFileResource() [ GenerisRdf::PROPERTY_FILE_FILENAME => $filename, GenerisRdf::PROPERTY_FILE_FILEPATH => $filePath, - GenerisRdf::PROPERTY_FILE_FILESYSTEM => $this->ontologyMock->getResource($this->testFile->getFileSystemId()), + GenerisRdf::PROPERTY_FILE_FILESYSTEM => $this->ontologyMock->getResource( + $this->testFile->getFileSystemId() + ), ] ); @@ -193,7 +195,9 @@ protected function tearDown(): void private function getMockFileSystem() { if ($this->fileSystemService === null) { - $this->fileSystemService = $this->getServiceLocatorMock([FileSystemService::SERVICE_ID => new FileSystemService()])->get(FileSystemService::SERVICE_ID); + $this->fileSystemService = $this + ->getServiceLocatorMock([FileSystemService::SERVICE_ID => new FileSystemService()]) + ->get(FileSystemService::SERVICE_ID); } return $this->fileSystemService; diff --git a/test/integration/helpers/FileTest.php b/test/integration/helpers/FileTest.php index e3c86b46f..dc53f5908 100644 --- a/test/integration/helpers/FileTest.php +++ b/test/integration/helpers/FileTest.php @@ -34,7 +34,8 @@ public function tearDown(): void public function setUp(): void { - $this->rootDir = uniqid(sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'test-file-inside-directory', true) . DIRECTORY_SEPARATOR; + $this->rootDir = uniqid(sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'test-file-inside-directory', true) + . DIRECTORY_SEPARATOR; mkdir($this->rootDir); mkdir($this->rootDir . 'directoryname'); @@ -63,6 +64,9 @@ public function fileInsideDirectoryDataProvider() */ public function testIsFileInsideDirectory($filename, $directoryName, bool $isInside) { - $this->assertEquals(\helpers_File::isFileInsideDirectory($filename, $this->rootDir . $directoryName), $isInside); + $this->assertEquals( + \helpers_File::isFileInsideDirectory($filename, $this->rootDir . $directoryName), + $isInside + ); } } diff --git a/test/integration/model/persistence/file/FileModelTest.php b/test/integration/model/persistence/file/FileModelTest.php index b80c35cbd..a00fb6bf1 100644 --- a/test/integration/model/persistence/file/FileModelTest.php +++ b/test/integration/model/persistence/file/FileModelTest.php @@ -127,7 +127,10 @@ public function testGetModelIdFromXml($id, $file) } catch (\Exception $e) { $this->assertInstanceOf('\common_exception_Error', $e); if ($id == 100) { - $this->assertContains('has to be defined with the "xml:base" attribute of the ROOT node', $e->getMessage()); + $this->assertContains( + 'has to be defined with the "xml:base" attribute of the ROOT node', + $e->getMessage() + ); } else { $this->fail('unexpected error'); } diff --git a/test/integration/model/persistence/smoothsql/SmoothsqlUtilsTest.php b/test/integration/model/persistence/smoothsql/SmoothsqlUtilsTest.php index dd75fd0f0..b83f43751 100644 --- a/test/integration/model/persistence/smoothsql/SmoothsqlUtilsTest.php +++ b/test/integration/model/persistence/smoothsql/SmoothsqlUtilsTest.php @@ -19,8 +19,8 @@ * (under the project TAO-TRANSFER); * 2009-2012 (update and modification) Public Research Centre Henri Tudor * (under the project TAO-SUSTAIN & TAO-DEV); - * 2012-2014 (update and modification) 2012-2014 (update and modification) Open Assessment Technologies SA (under the project TAO-PRODUCT); - * + * 2012-2014 (update and modification) 2012-2014 (update and modification) Open Assessment Technologies SA + * (under the project TAO-PRODUCT); */ namespace oat\generis\test\integration\model\persistence\smoothsql; @@ -58,7 +58,14 @@ public function __construct($name = null, array $data = [], $dataName = '') */ public function testBuildSearchPattern($pattern, $like, $expected) { - $this->assertSame($expected, core_kernel_persistence_smoothsql_Utils::buildSearchPattern($this->getModel()->getPersistence(), $pattern, $like)); + $this->assertSame( + $expected, + core_kernel_persistence_smoothsql_Utils::buildSearchPattern( + $this->getModel()->getPersistence(), + $pattern, + $like + ) + ); } public function buildSearchPatternProvider() @@ -76,8 +83,16 @@ public function buildSearchPatternProvider() [false, false, '= ' . $this->quote('')], [false, true, 'LIKE LOWER(' . $this->quote('%%') . ')'], ['', true, 'LIKE LOWER(' . $this->quote('%%') . ')'], - [new core_kernel_classes_Resource('http://www.13.com/ontology#toto'), false, '= ' . $this->quote('http://www.13.com/ontology#toto')], - [new core_kernel_classes_Resource('http://www.13.com/ontology#toto'), true, '= ' . $this->quote('http://www.13.com/ontology#toto')], + [ + new core_kernel_classes_Resource('http://www.13.com/ontology#toto'), + false, + '= ' . $this->quote('http://www.13.com/ontology#toto') + ], + [ + new core_kernel_classes_Resource('http://www.13.com/ontology#toto'), + true, + '= ' . $this->quote('http://www.13.com/ontology#toto') + ], ]; } @@ -91,7 +106,13 @@ public function buildSearchPatternProvider() */ public function testBuildPropertyQuery($expected, $propertyUri, $values, $like, $lang = '') { - $query = core_kernel_persistence_smoothsql_Utils::buildPropertyQuery($this->getModel(), $propertyUri, $values, $like, $lang); + $query = core_kernel_persistence_smoothsql_Utils::buildPropertyQuery( + $this->getModel(), + $propertyUri, + $values, + $like, + $lang + ); $queryWithoutModelRestrictions = substr($query, 0, strlen($expected)); $this->assertSame($expected, $queryWithoutModelRestrictions); $this->assertSame(' AND modelid IN (', substr($query, strlen($expected), strlen(' AND modelid IN ('))); @@ -101,25 +122,35 @@ public function buildPropertyQueryProvider() { return [ [ - "SELECT DISTINCT subject FROM statements WHERE (predicate = " . $this->quote('http://www.13.com/ontology#prop') . ") AND (object = " . $this->quote('hello') . ")", + "SELECT DISTINCT subject FROM statements WHERE (predicate = " + . $this->quote('http://www.13.com/ontology#prop') . ") AND (object = " + . $this->quote('hello') . ")", 'http://www.13.com/ontology#prop', 'hello', false ], [ - "SELECT DISTINCT subject FROM statements WHERE (predicate = " . $this->quote('http://www.13.com/ontology#prop') . ") AND (object = " . $this->quote('hello') . " OR object = " . $this->quote('world') . ")", + "SELECT DISTINCT subject FROM statements WHERE (predicate = " + . $this->quote('http://www.13.com/ontology#prop') . ") AND (object = " + . $this->quote('hello') . " OR object = " . $this->quote('world') . ")", 'http://www.13.com/ontology#prop', ['hello', 'world'], false ], [ - "SELECT DISTINCT subject FROM statements WHERE (predicate = " . $this->quote('http://www.13.com/ontology#prop') . ") AND (LOWER(object) LIKE LOWER(" . $this->quote('%hello%') . ") OR LOWER(object) LIKE LOWER(" . $this->quote('%world%') . "))", + "SELECT DISTINCT subject FROM statements WHERE (predicate = " + . $this->quote('http://www.13.com/ontology#prop') . ") AND (LOWER(object) LIKE LOWER(" + . $this->quote('%hello%') . ") OR LOWER(object) LIKE LOWER(" . $this->quote('%world%') + . "))", 'http://www.13.com/ontology#prop', ['hello', 'world'], true ], [ - "SELECT DISTINCT subject FROM statements WHERE (predicate = " . $this->quote('http://www.13.com/ontology#prop') . ") AND (object = " . $this->quote('hello') . " AND (l_language = " . $this->quote('') . " OR l_language = " . $this->quote('en-US') . "))", + "SELECT DISTINCT subject FROM statements WHERE (predicate = " + . $this->quote('http://www.13.com/ontology#prop') . ") AND (object = " + . $this->quote('hello') . " AND (l_language = " . $this->quote('') . " OR l_language = " + . $this->quote('en-US') . "))", 'http://www.13.com/ontology#prop', 'hello', false, @@ -144,16 +175,50 @@ public function buildUnionQueryProvider() return [ [ [ - core_kernel_persistence_smoothsql_Utils::buildPropertyQuery($this->getModel(), 'http://www.13.com/ontology#prop1', 'toto', false), - core_kernel_persistence_smoothsql_Utils::buildPropertyQuery($this->getModel(), 'http://www.13.com/ontology#prop2', 'tata', false), + core_kernel_persistence_smoothsql_Utils::buildPropertyQuery( + $this->getModel(), + 'http://www.13.com/ontology#prop1', + 'toto', + false + ), + core_kernel_persistence_smoothsql_Utils::buildPropertyQuery( + $this->getModel(), + 'http://www.13.com/ontology#prop2', + 'tata', + false + ), ], - '(' . core_kernel_persistence_smoothsql_Utils::buildPropertyQuery($this->getModel(), 'http://www.13.com/ontology#prop1', 'toto', false) . ') UNION ALL (' . core_kernel_persistence_smoothsql_Utils::buildPropertyQuery($this->getModel(), 'http://www.13.com/ontology#prop2', 'tata', false) . ')' + '(' + . core_kernel_persistence_smoothsql_Utils::buildPropertyQuery( + $this->getModel(), + 'http://www.13.com/ontology#prop1', + 'toto', + false + ) + . ') UNION ALL (' + . core_kernel_persistence_smoothsql_Utils::buildPropertyQuery( + $this->getModel(), + 'http://www.13.com/ontology#prop2', + 'tata', + false + ) + . ')' ], [ [ - core_kernel_persistence_smoothsql_Utils::buildPropertyQuery($this->getModel(), 'http://www.13.com/ontology#prop1', 'toto', false) + core_kernel_persistence_smoothsql_Utils::buildPropertyQuery( + $this->getModel(), + 'http://www.13.com/ontology#prop1', + 'toto', + false + ) ], - core_kernel_persistence_smoothsql_Utils::buildPropertyQuery($this->getModel(), 'http://www.13.com/ontology#prop1', 'toto', false) + core_kernel_persistence_smoothsql_Utils::buildPropertyQuery( + $this->getModel(), + 'http://www.13.com/ontology#prop1', + 'toto', + false + ) ], [[], false] ]; diff --git a/test/integration/mutex/LockServiceTest.php b/test/integration/mutex/LockServiceTest.php index 995924d58..1744162d9 100644 --- a/test/integration/mutex/LockServiceTest.php +++ b/test/integration/mutex/LockServiceTest.php @@ -44,10 +44,22 @@ public function testLock() $actionId2 = 'action_2'; $sleep = 3; $time = time(); - $pipe1 = popen('php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId1 . ' ' . $sleep . ' 0', 'w'); - $pipe2 = popen('php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId1 . ' ' . $sleep . ' 0', 'w'); - $pipe3 = popen('php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId1 . ' ' . $sleep . ' 0', 'w'); - $pipe4 = popen('php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId2 . ' ' . $sleep . ' 0', 'w'); + $pipe1 = popen( + 'php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId1 . ' ' . $sleep . ' 0', + 'w' + ); + $pipe2 = popen( + 'php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId1 . ' ' . $sleep . ' 0', + 'w' + ); + $pipe3 = popen( + 'php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId1 . ' ' . $sleep . ' 0', + 'w' + ); + $pipe4 = popen( + 'php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId2 . ' ' . $sleep . ' 0', + 'w' + ); pclose($pipe1); pclose($pipe2); pclose($pipe3); @@ -66,8 +78,14 @@ public function testLockTimeout() $sleep = 5; $timeout = 2; $time = time(); - $pipe1 = popen('php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId1 . ' ' . $sleep . ' ' . $timeout, 'w'); - $pipe2 = popen('php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId1 . ' ' . $sleep . ' ' . $timeout, 'w'); + $pipe1 = popen( + 'php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId1 . ' ' . $sleep . ' ' . $timeout, + 'w' + ); + $pipe2 = popen( + 'php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId1 . ' ' . $sleep . ' ' . $timeout, + 'w' + ); pclose($pipe1); pclose($pipe2); diff --git a/test/integration/rules/ExpressionFactoryTest.php b/test/integration/rules/ExpressionFactoryTest.php index fa9711666..8859c8f66 100644 --- a/test/integration/rules/ExpressionFactoryTest.php +++ b/test/integration/rules/ExpressionFactoryTest.php @@ -41,7 +41,10 @@ public function testCreateTerminalExpression() { $constantResource = core_kernel_rules_TermFactory::createConst('test1'); $terminalExpression = core_kernel_rules_ExpressionFactory::createTerminalExpression($constantResource); - $terminalExpressionProperty = new core_kernel_classes_Property(RulesRdf::PROPERTY_TERMINAL_EXPRESSION, __METHOD__); + $terminalExpressionProperty = new core_kernel_classes_Property( + RulesRdf::PROPERTY_TERMINAL_EXPRESSION, + __METHOD__ + ); $terminalExpressionVal = $terminalExpression->getOnePropertyValue($terminalExpressionProperty); $this->assertIsA($terminalExpressionVal, 'core_kernel_classes_Resource'); $this->assertEquals($terminalExpressionVal->getUri(), $constantResource->getUri()); @@ -63,10 +66,17 @@ public function testCreateRecursiveExpression() $terminalExpression2 = core_kernel_rules_ExpressionFactory::createTerminalExpression($constantResource2); $equalsOperator = new core_kernel_classes_Resource(RulesRdf::INSTANCE_EQUALS_OPERATOR_URI); - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($terminalExpression1, $terminalExpression2, $equalsOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $terminalExpression1, + $terminalExpression2, + $equalsOperator + ); //prop - $terminalExpressionProperty = new core_kernel_classes_Property(RulesRdf::PROPERTY_TERMINAL_EXPRESSION, __METHOD__); + $terminalExpressionProperty = new core_kernel_classes_Property( + RulesRdf::PROPERTY_TERMINAL_EXPRESSION, + __METHOD__ + ); $logicalOperatorProperty = new core_kernel_classes_Property(RulesRdf::PROPERTY_HASLOGICALOPERATOR, __METHOD__); $firstExpressionProperty = new core_kernel_classes_Property(RulesRdf::PROPERTY_FIRST_EXPRESSION, __METHOD__); $secondExpressionProperty = new core_kernel_classes_Property(RulesRdf::PROPERTY_SECOND_EXPRESSION, __METHOD__); diff --git a/test/integration/rules/ExpressionTest.php b/test/integration/rules/ExpressionTest.php index b8d1d3825..fc3599da3 100644 --- a/test/integration/rules/ExpressionTest.php +++ b/test/integration/rules/ExpressionTest.php @@ -53,143 +53,263 @@ public function testEvaluate() // test1 == test2 $equalsOperator = new core_kernel_classes_Resource(RulesRdf::INSTANCE_EQUALS_OPERATOR_URI); - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($terminalExpression1, $terminalExpression2, $equalsOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $terminalExpression1, + $terminalExpression2, + $equalsOperator + ); $this->assertFalse($finalExpression->evaluate()); $finalExpression->delete(); // 12 == 12 - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($terminalExpression12, $terminalExpression12b, $equalsOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $terminalExpression12, + $terminalExpression12b, + $equalsOperator + ); $this->assertTrue($finalExpression->evaluate()); $finalExpression->delete(); // test1 != test2 $diffOperator = new core_kernel_classes_Resource(RulesRdf::INSTANCE_DIFFERENT_OPERATOR_URI); - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($terminalExpression1, $terminalExpression2, $diffOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $terminalExpression1, + $terminalExpression2, + $diffOperator + ); $this->assertTrue($finalExpression->evaluate()); $finalExpression->delete(); // 12 != 12 - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($terminalExpression12, $terminalExpression12b, $diffOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $terminalExpression12, + $terminalExpression12b, + $diffOperator + ); $this->assertFalse($finalExpression->evaluate()); $finalExpression->delete(); // 14 <= 12 $infEqOperator = new core_kernel_classes_Resource(RulesRdf::INSTANCE_INF_EQ_OPERATOR_URI); - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($terminalExpression14, $terminalExpression12, $infEqOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $terminalExpression14, + $terminalExpression12, + $infEqOperator + ); $this->assertFalse($finalExpression->evaluate()); $finalExpression->delete(); //12 <= 14 - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($terminalExpression12, $terminalExpression14, $infEqOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $terminalExpression12, + $terminalExpression14, + $infEqOperator + ); $this->assertTrue($finalExpression->evaluate()); $finalExpression->delete(); //12 <= 12 - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($terminalExpression12, $terminalExpression12b, $infEqOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $terminalExpression12, + $terminalExpression12b, + $infEqOperator + ); $this->assertTrue($finalExpression->evaluate()); $finalExpression->delete(); // 14 >= 12 $supEqOperator = new core_kernel_classes_Resource(RulesRdf::INSTANCE_SUP_EQ_OPERATOR_URI); - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($terminalExpression14, $terminalExpression12, $supEqOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $terminalExpression14, + $terminalExpression12, + $supEqOperator + ); $this->assertTrue($finalExpression->evaluate()); $finalExpression->delete(); //12 >= 14 - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($terminalExpression12, $terminalExpression14, $supEqOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $terminalExpression12, + $terminalExpression14, + $supEqOperator + ); $this->assertFalse($finalExpression->evaluate()); $finalExpression->delete(); //12 >= 12 - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($terminalExpression12, $terminalExpression12b, $supEqOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $terminalExpression12, + $terminalExpression12b, + $supEqOperator + ); $this->assertTrue($finalExpression->evaluate()); $finalExpression->delete(); // 14 < 12 $infOperator = new core_kernel_classes_Resource(RulesRdf::INSTANCE_INF_OPERATOR_URI); - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($terminalExpression14, $terminalExpression12, $infOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $terminalExpression14, + $terminalExpression12, + $infOperator + ); $this->assertFalse($finalExpression->evaluate()); $finalExpression->delete(); //12 < 14 - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($terminalExpression12, $terminalExpression14, $infOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $terminalExpression12, + $terminalExpression14, + $infOperator + ); $this->assertTrue($finalExpression->evaluate()); $finalExpression->delete(); //12 < 12 - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($terminalExpression12, $terminalExpression12b, $infOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $terminalExpression12, + $terminalExpression12b, + $infOperator + ); $this->assertFalse($finalExpression->evaluate()); $finalExpression->delete(); // 14 > 12 $supOperator = new core_kernel_classes_Resource(RulesRdf::INSTANCE_SUP_OPERATOR_URI); - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($terminalExpression14, $terminalExpression12, $supOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $terminalExpression14, + $terminalExpression12, + $supOperator + ); $this->assertTrue($finalExpression->evaluate()); $finalExpression->delete(); //12 > 14 - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($terminalExpression12, $terminalExpression14, $supOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $terminalExpression12, + $terminalExpression14, + $supOperator + ); $this->assertFalse($finalExpression->evaluate()); $finalExpression->delete(); //12 > 12 - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($terminalExpression12, $terminalExpression12b, $supOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $terminalExpression12, + $terminalExpression12b, + $supOperator + ); $this->assertFalse($finalExpression->evaluate()); $finalExpression->delete(); // trueExpression => 12 < 14 - $trueExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($terminalExpression12, $terminalExpression14, $infOperator); + $trueExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $terminalExpression12, + $terminalExpression14, + $infOperator + ); //falseExpression => test1 == test2 - $falseExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($terminalExpression1, $terminalExpression2, $equalsOperator); + $falseExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $terminalExpression1, + $terminalExpression2, + $equalsOperator + ); // trueExpression2 => test1 != test2 - $trueExpression2 = core_kernel_rules_ExpressionFactory::createRecursiveExpression($terminalExpression1, $terminalExpression2, $diffOperator); + $trueExpression2 = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $terminalExpression1, + $terminalExpression2, + $diffOperator + ); //falseExpression2 => 14 < 12 - $falseExpression2 = core_kernel_rules_ExpressionFactory::createRecursiveExpression($terminalExpression14, $terminalExpression12, $infOperator); + $falseExpression2 = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $terminalExpression14, + $terminalExpression12, + $infOperator + ); // 12 < 14 AND test1 == test2 $andOperator = new core_kernel_classes_Resource(RulesRdf::INSTANCE_AND_OPERATOR); - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($trueExpression, $falseExpression, $andOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $trueExpression, + $falseExpression, + $andOperator + ); $this->assertFalse($finalExpression->evaluate()); $finalExpression->delete(); // 12 < 14 AND test1 != test2 - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($trueExpression, $trueExpression2, $andOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $trueExpression, + $trueExpression2, + $andOperator + ); $this->assertTrue($finalExpression->evaluate()); $finalExpression->delete(); // 12 < 14 OR test1 == test2 $orOperator = new core_kernel_classes_Resource(RulesRdf::INSTANCE_OR_OPERATOR); - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($trueExpression, $falseExpression, $orOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $trueExpression, + $falseExpression, + $orOperator + ); $this->assertTrue($finalExpression->evaluate()); $finalExpression->delete(); // 12 < 14 OR test1 != test2 - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($trueExpression, $trueExpression2, $orOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $trueExpression, + $trueExpression2, + $orOperator + ); $this->assertTrue($finalExpression->evaluate()); $finalExpression->delete(); // test1 == test2 OR 12 < 14 - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($falseExpression, $trueExpression, $orOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $falseExpression, + $trueExpression, + $orOperator + ); $this->assertTrue($finalExpression->evaluate()); $finalExpression->delete(); // test1 == test2 OR 14 < 12 - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($falseExpression, $falseExpression2, $orOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $falseExpression, + $falseExpression2, + $orOperator + ); $this->assertFalse($finalExpression->evaluate()); $finalExpression->delete(); // (test1 == test2 OR 14 < 12) AND (12 < 14 OR test1 == test2) - $finalExpression1 = core_kernel_rules_ExpressionFactory::createRecursiveExpression($falseExpression, $falseExpression2, $orOperator); - $finalExpression2 = core_kernel_rules_ExpressionFactory::createRecursiveExpression($trueExpression, $falseExpression, $orOperator); - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($finalExpression1, $finalExpression2, $andOperator); + $finalExpression1 = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $falseExpression, + $falseExpression2, + $orOperator + ); + $finalExpression2 = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $trueExpression, + $falseExpression, + $orOperator + ); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $finalExpression1, + $finalExpression2, + $andOperator + ); $this->assertFalse($finalExpression->evaluate()); $finalExpression->delete(); // (test1 == test2 OR 14 < 12) OR (12 < 14 OR test1 == test2) - $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression($finalExpression1, $finalExpression2, $orOperator); + $finalExpression = core_kernel_rules_ExpressionFactory::createRecursiveExpression( + $finalExpression1, + $finalExpression2, + $orOperator + ); $this->assertTrue($finalExpression->evaluate()); $finalExpression->delete(); diff --git a/test/integration/rules/TermFactoryTest.php b/test/integration/rules/TermFactoryTest.php index 0c74ebb5e..c11a31527 100644 --- a/test/integration/rules/TermFactoryTest.php +++ b/test/integration/rules/TermFactoryTest.php @@ -70,7 +70,10 @@ public function testCreateSPX() $booleanClass = new core_kernel_classes_Class(GenerisRdf::GENERIS_BOOLEAN); $maybe = core_kernel_classes_ResourceFactory::create($booleanClass, 'testCase testCreateSPX', __METHOD__); - $SPXResource = core_kernel_rules_TermFactory::createSPX($maybe, new core_kernel_classes_Property(OntologyRdfs::RDFS_COMMENT)); + $SPXResource = core_kernel_rules_TermFactory::createSPX( + $maybe, + new core_kernel_classes_Property(OntologyRdfs::RDFS_COMMENT) + ); $this->assertIsA($SPXResource, 'core_kernel_rules_Term'); $subjectProperty = new core_kernel_classes_Property(RulesRdf::PROPERTY_TERM_SPX_SUBJET); diff --git a/test/integration/rules/TermTest.php b/test/integration/rules/TermTest.php index ee706be75..98ed5adfa 100644 --- a/test/integration/rules/TermTest.php +++ b/test/integration/rules/TermTest.php @@ -67,7 +67,10 @@ public function testEvaluate() $booleanClass = new core_kernel_classes_Class(GenerisRdf::GENERIS_BOOLEAN); $maybe = core_kernel_classes_ResourceFactory::create($booleanClass, 'testCase testCreateSPX', __METHOD__); - $SPXResource = core_kernel_rules_TermFactory::createSPX($maybe, new core_kernel_classes_Property(OntologyRdfs::RDFS_COMMENT)); + $SPXResource = core_kernel_rules_TermFactory::createSPX( + $maybe, + new core_kernel_classes_Property(OntologyRdfs::RDFS_COMMENT) + ); $spxResult = $SPXResource->evaluate(); $this->assertIsA($spxResult, 'core_kernel_classes_Literal'); $this->assertEquals($spxResult, __METHOD__); diff --git a/test/samples/manifests/complexManifest.php b/test/samples/manifests/complexManifest.php index 92585b34c..6a5ef3da3 100644 --- a/test/samples/manifests/complexManifest.php +++ b/test/samples/manifests/complexManifest.php @@ -45,8 +45,23 @@ ['type' => 'CheckPHPExtension', 'value' => ['id' => 'ext_pdo', 'name' => 'PDO']], ['type' => 'CheckPHPExtension', 'value' => ['id' => 'ext_svn','name' => 'svn', 'optional' => true]], ['type' => 'CheckPHPExtension', 'value' => ['id' => 'ext_suhosin','name' => 'suhosin', 'optional' => true]], - ['type' => 'CheckPHPINIValue', 'value' => ['id' => 'ini_register_globals', 'name' => 'register_globals', 'value' => "0"]], - ['type' => 'CheckFileSystemComponent', 'value' => ['id' => 'fs_root','location' => '.', 'rights' => 'rw', 'name' => 'fs_root']], + [ + 'type' => 'CheckPHPINIValue', + 'value' => [ + 'id' => 'ini_register_globals', + 'name' => 'register_globals', + 'value' => "0" + ] + ], + [ + 'type' => 'CheckFileSystemComponent', + 'value' => [ + 'id' => 'fs_root', + 'location' => '.', + 'rights' => 'rw', + 'name' => 'fs_root' + ] + ], ] ], 'constants' => [ diff --git a/test/unit/ConfigurationTest.php b/test/unit/ConfigurationTest.php index 4b19f3c55..00a3837b9 100755 --- a/test/unit/ConfigurationTest.php +++ b/test/unit/ConfigurationTest.php @@ -40,7 +40,11 @@ class ConfigurationTest extends TestCase public function testPhPConstant() { - $this->assertNotEquals(PHP_MAJOR_VERSION, self::UNSUPPORTED_PHP_MAJOR_VERSION, 'Current php major version equals our assummed unsupported php version'); + $this->assertNotEquals( + PHP_MAJOR_VERSION, + self::UNSUPPORTED_PHP_MAJOR_VERSION, + 'Current php major version equals our assummed unsupported php version' + ); } public function testPHPIniValues() @@ -280,7 +284,10 @@ public function testSimpleComponentCollection() $reports = $collection->check(); $this->assertTrue(true); // Acyclic graph, no CyclicDependencyException thrown. $this->assertEquals(count($reports), 4); - $this->assertEquals($collection->getCheckedComponents(), [$componentA, $componentB, $componentC, $componentD]); + $this->assertEquals( + $collection->getCheckedComponents(), + [$componentA, $componentB, $componentC, $componentD] + ); $this->assertEquals($collection->getUncheckedComponents(), []); try { @@ -292,7 +299,10 @@ public function testSimpleComponentCollection() $this->assertTrue(true); $this->assertEquals($collection->getReports(), []); $this->assertEquals($collection->getCheckedComponents(), []); - $this->assertEquals($collection->getUncheckedComponents(), [$componentA, $componentB, $componentC, $componentD]); + $this->assertEquals( + $collection->getUncheckedComponents(), + [$componentA, $componentB, $componentC, $componentD] + ); // Finally, we test a ComponentCollection reset. $collection->reset(); diff --git a/test/unit/FileHelperTest.php b/test/unit/FileHelperTest.php index b20465ccb..8fba71ee2 100755 --- a/test/unit/FileHelperTest.php +++ b/test/unit/FileHelperTest.php @@ -60,7 +60,8 @@ private function mkdir($basePath) /** * @todo fix problematic test case - * why does this case try to read files 'ExpressionFactoryTest.php', 'ExpressionTest.php', 'OperationFactoryTest.php', 'OperationTest.php', 'TermFactoryTest.php', 'TermTest.php'? + * why does this case try to read files 'ExpressionFactoryTest.php', 'ExpressionTest.php', + * 'OperationFactoryTest.php', 'OperationTest.php', 'TermFactoryTest.php', 'TermTest.php'? * * * @dataProvider scandirDataProvider @@ -72,7 +73,10 @@ private function mkdir($basePath) */ public function testScandir($toScan, $expectedResult, $recursive = false, $absolute = false) { - $result = helpers_File::scanDir($toScan, ['recursive' => $recursive, 'absolute' => $absolute, 'only' => helpers_File::SCAN_FILE]); + $result = helpers_File::scanDir( + $toScan, + ['recursive' => $recursive, 'absolute' => $absolute, 'only' => helpers_File::SCAN_FILE] + ); $this->assertEquals(count($expectedResult), count($result)); // The order might vary depending on the file system implementation... foreach ($expectedResult as $expected) { @@ -124,7 +128,8 @@ public function containsFileTypeProvider() public function testUrlToPath() { - $path = DIRECTORY_SEPARATOR . 'style' . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'tao-user-styles.css'; + $path = DIRECTORY_SEPARATOR . 'style' . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR + . 'tao-user-styles.css'; $urls = [ '/style/custom/tao-user-styles.css', diff --git a/test/unit/ManifestTest.php b/test/unit/ManifestTest.php index b39bd8224..3d2ab0a60 100755 --- a/test/unit/ManifestTest.php +++ b/test/unit/ManifestTest.php @@ -96,6 +96,12 @@ public function testManifestLoading() ], $manifest->getInstallModelFiles() ); - $this->assertEquals(['WS_ENDPOINT_TWITTER' => 'http://twitter.com/statuses/', 'WS_ENDPOINT_FACEBOOK' => 'http://api.facebook.com/restserver.php'], $manifest->getConstants()); + $this->assertEquals( + [ + 'WS_ENDPOINT_TWITTER' => 'http://twitter.com/statuses/', + 'WS_ENDPOINT_FACEBOOK' => 'http://api.facebook.com/restserver.php' + ], + $manifest->getConstants() + ); } } diff --git a/test/unit/UtilsTest.php b/test/unit/UtilsTest.php index 6e00852c8..e79dd9076 100755 --- a/test/unit/UtilsTest.php +++ b/test/unit/UtilsTest.php @@ -105,6 +105,23 @@ private function buildBinString() $score = "\x01" . pack('S', 8) . "\x00" . "\x01" . pack('d', 1.0); $response = "\x00" . pack('S', 0) . "\x00" . "\x01" . pack('S', 7) . 'ChoiceA'; - return implode('', [$position, $state, $navigationMode, $submissionMode, $attempting, $hasItemSessionControl, $numAttempts, $duration, $completionStatus, $timeReference, $varCount, $score, $response]); + return implode( + '', + [ + $position, + $state, + $navigationMode, + $submissionMode, + $attempting, + $hasItemSessionControl, + $numAttempts, + $duration, + $completionStatus, + $timeReference, + $varCount, + $score, + $response + ] + ); } } diff --git a/test/unit/common/configuration/ComponentFactoryTest.php b/test/unit/common/configuration/ComponentFactoryTest.php index f30f5779b..3688eaa55 100644 --- a/test/unit/common/configuration/ComponentFactoryTest.php +++ b/test/unit/common/configuration/ComponentFactoryTest.php @@ -129,16 +129,35 @@ public function testBuildFromArray() $output = $this->subject->buildFromArray(['type' => 'PHPRuntime', 'value' => ['min' => 1, 'max' => 2]]); $this->assertInstanceOf(common_configuration_PHPRuntime::class, $output); - $output = $this->subject->buildFromArray(['type' => 'PHPINIValue', 'value' => ['name' => 'name', 'value' => 'value']]); + $output = $this->subject->buildFromArray([ + 'type' => 'PHPINIValue', + 'value' => [ + 'name' => 'name', + 'value' => 'value' + ] + ]); $this->assertInstanceOf(common_configuration_PHPINIValue::class, $output); - $output = $this->subject->buildFromArray(['type' => 'PHPExtension', 'value' => ['name' => 'name', 'min' => 1, 'max' => 2]]); + $output = $this->subject->buildFromArray([ + 'type' => 'PHPExtension', + 'value' => [ + 'name' => 'name', + 'min' => 1, + 'max' => 2 + ] + ]); $this->assertInstanceOf(common_configuration_PHPExtension::class, $output); $output = $this->subject->buildFromArray(['type' => 'PHPDatabaseDriver', 'value' => ['name' => 'name']]); $this->assertInstanceOf(common_configuration_PHPDatabaseDriver::class, $output); - $output = $this->subject->buildFromArray(['type' => 'FileSystemComponent', 'value' => ['location' => '/path', 'rights' => 'rw']]); + $output = $this->subject->buildFromArray([ + 'type' => 'FileSystemComponent', + 'value' => [ + 'location' => '/path', + 'rights' => 'rw' + ] + ]); $this->assertInstanceOf(common_configuration_FileSystemComponent::class, $output); $output = $this->subject->buildFromArray(['type' => 'Mock', 'value' => ['status' => '/status']]); diff --git a/test/unit/common/configuration/FileSystemComponentTest.php b/test/unit/common/configuration/FileSystemComponentTest.php index 6cf17c999..df7e52802 100644 --- a/test/unit/common/configuration/FileSystemComponentTest.php +++ b/test/unit/common/configuration/FileSystemComponentTest.php @@ -125,7 +125,8 @@ public function testCheckDirectoryPermissionsSuccess() $this->assertEquals(common_configuration_Report::VALID, $output->getStatus()); $this->assertEquals( - "File system component 'tao.configuration.filesystem' in 'vfs://testDir7 is compliant with expected rights (rw).'", + "File system component 'tao.configuration.filesystem' in " + . "'vfs://testDir7 is compliant with expected rights (rw).'", $output->getMessage() ); } @@ -145,7 +146,8 @@ public function testCheckFilePermissionsSuccess() $this->assertEquals(common_configuration_Report::VALID, $output->getStatus()); $this->assertEquals( - "File system component 'tao.configuration.filesystem' in 'vfs://testDir8/test.txt is compliant with expected rights (rwx).'", + "File system component 'tao.configuration.filesystem' in " + . "'vfs://testDir8/test.txt is compliant with expected rights (rwx).'", $output->getMessage() ); } @@ -185,7 +187,8 @@ public function testCheckDirectoryContentSuccess() $this->assertEquals(common_configuration_Report::VALID, $output->getStatus()); $this->assertEquals( - "File system component 'tao.configuration.filesystem' in 'vfs://testDir10 is compliant with expected rights (rw).'", + "File system component 'tao.configuration.filesystem' in " + . "'vfs://testDir10 is compliant with expected rights (rw).'", $output->getMessage() ); } diff --git a/test/unit/common/persistence/AdvKeyValuePersistenceTest.php b/test/unit/common/persistence/AdvKeyValuePersistenceTest.php index 17cba5332..623af4750 100644 --- a/test/unit/common/persistence/AdvKeyValuePersistenceTest.php +++ b/test/unit/common/persistence/AdvKeyValuePersistenceTest.php @@ -245,9 +245,15 @@ public function testHDelSmallValue(): void $storedValue = $this->largeValuePersistence->hGet($key, $field); self::assertSame($value, $storedValue, 'The same value must be returned from persistence.'); - self::assertTrue($this->largeValuePersistence->hDel($key, $field), 'Method must return FALSE when value was deleted.'); + self::assertTrue( + $this->largeValuePersistence->hDel($key, $field), + 'Method must return FALSE when value was deleted.' + ); self::assertFalse($this->largeValuePersistence->hGet($key, $field), 'Value must be deleted from persistence.'); - self::assertFalse($this->largeValuePersistence->hDel($key, $field), 'Method must return FALSE when key/field does not exist.'); + self::assertFalse( + $this->largeValuePersistence->hDel($key, $field), + 'Method must return FALSE when key/field does not exist.' + ); } public function testHDelLargeValue(): void @@ -272,13 +278,22 @@ public function testHDelLargeValue(): void $keyMap = array_values($this->largeValuePersistence->get($key))[0]; $keyMap = json_decode(substr_replace($keyMap, '', 0, strlen($startMapDelimiter)), true); $mappedKye = $startMapDelimiter . $keyMap[0] . $endMapDelimiter; - self::assertFalse($this->largeValuePersistence->hDel($key, $mappedKye), 'It should not be allowed to delete one part of large value.'); + self::assertFalse( + $this->largeValuePersistence->hDel($key, $mappedKye), + 'It should not be allowed to delete one part of large value.' + ); $storedValue = $this->largeValuePersistence->hGet($key, $field); self::assertSame($value, $storedValue, 'The same value must be returned from persistence.'); - self::assertTrue($this->largeValuePersistence->hDel($key, $field), 'Method must return FALSE when value was deleted.'); + self::assertTrue( + $this->largeValuePersistence->hDel($key, $field), + 'Method must return FALSE when value was deleted.' + ); self::assertFalse($this->largeValuePersistence->hGet($key, $field), 'Value must be deleted from persistence.'); - self::assertFalse($this->largeValuePersistence->hDel($key, $field), 'Method must return FALSE when key/field does not exist.'); + self::assertFalse( + $this->largeValuePersistence->hDel($key, $field), + 'Method must return FALSE when key/field does not exist.' + ); } } diff --git a/test/unit/helpers/FileTest.php b/test/unit/helpers/FileTest.php index 731b1c70a..733a95558 100644 --- a/test/unit/helpers/FileTest.php +++ b/test/unit/helpers/FileTest.php @@ -51,13 +51,28 @@ public function testInDirectory() $this->assertFalse(\helpers_File::isFileInsideDirectory('test2.txt', $this->dir)); $this->assertTrue(\helpers_File::isFileInsideDirectory('test1.txt', $this->dir . DIRECTORY_SEPARATOR)); $this->assertFalse(\helpers_File::isFileInsideDirectory('sub' . DIRECTORY_SEPARATOR . 'test2.txt', $this->dir)); - $this->assertFalse(\helpers_File::isFileInsideDirectory('sub' . DIRECTORY_SEPARATOR . 'test2.txt', $this->dir . DIRECTORY_SEPARATOR)); + $this->assertFalse( + \helpers_File::isFileInsideDirectory( + 'sub' . DIRECTORY_SEPARATOR . 'test2.txt', + $this->dir . DIRECTORY_SEPARATOR + ) + ); $this->assertFalse(\helpers_File::isFileInsideDirectory('test1.txt', $this->subDir)); $this->assertFalse(\helpers_File::isFileInsideDirectory('test1.txt', $this->subDir . DIRECTORY_SEPARATOR)); $this->assertTrue(\helpers_File::isFileInsideDirectory('test2.txt', $this->subDir)); - $this->assertFalse(\helpers_File::isFileInsideDirectory('sub' . DIRECTORY_SEPARATOR . 'test2.txt', $this->subDir)); - $this->assertFalse(\helpers_File::isFileInsideDirectory('sub' . DIRECTORY_SEPARATOR . 'test2.txt', $this->subDir . DIRECTORY_SEPARATOR)); + $this->assertFalse( + \helpers_File::isFileInsideDirectory( + 'sub' . DIRECTORY_SEPARATOR . 'test2.txt', + $this->subDir + ) + ); + $this->assertFalse( + \helpers_File::isFileInsideDirectory( + 'sub' . DIRECTORY_SEPARATOR . 'test2.txt', + $this->subDir . DIRECTORY_SEPARATOR + ) + ); } protected function tearDown(): void diff --git a/test/unit/model/data/permission/FreeAccessTest.php b/test/unit/model/data/permission/FreeAccessTest.php index e3bd4826b..6ad621564 100644 --- a/test/unit/model/data/permission/FreeAccessTest.php +++ b/test/unit/model/data/permission/FreeAccessTest.php @@ -50,7 +50,10 @@ public function testGetPermissions() { $model = new FreeAccess(); $this->assertEquals(['res1' => [FreeAccess::RIGHT_UNSUPPORTED]], $model->getPermissions($this->user, ['res1'])); - $this->assertEquals(['res1' => [FreeAccess::RIGHT_UNSUPPORTED], 'res2' => [FreeAccess::RIGHT_UNSUPPORTED]], $model->getPermissions($this->user, ['res1', 'res2'])); + $this->assertEquals( + ['res1' => [FreeAccess::RIGHT_UNSUPPORTED], 'res2' => [FreeAccess::RIGHT_UNSUPPORTED]], + $model->getPermissions($this->user, ['res1', 'res2']) + ); } public function testGetSupportedRights() @@ -66,6 +69,9 @@ public function testPhpSerialize() $this->assertInstanceOf('oat\generis\model\data\permission\PermissionInterface', $restoredModel); $this->assertEquals([], $restoredModel->getSupportedRights()); - $this->assertEquals(['res1' => [FreeAccess::RIGHT_UNSUPPORTED]], $restoredModel->getPermissions($this->user, ['res1'])); + $this->assertEquals( + ['res1' => [FreeAccess::RIGHT_UNSUPPORTED]], + $restoredModel->getPermissions($this->user, ['res1']) + ); } } diff --git a/test/unit/model/data/permission/IntersectionTest.php b/test/unit/model/data/permission/IntersectionTest.php index 9087f8dec..29a2bf150 100644 --- a/test/unit/model/data/permission/IntersectionTest.php +++ b/test/unit/model/data/permission/IntersectionTest.php @@ -58,11 +58,21 @@ private function createIntersection() $permissionModel3->getPermissions($this->user, ['res1'])->willReturn(['res1' => ['rightC']]); // res2 - $permissionModel1->getPermissions($this->user, ['res1', 'res2'])->willReturn(['res1' => ['rightA', 'rightC'], 'res2' => []]); - $permissionModel2->getPermissions($this->user, ['res1', 'res2'])->willReturn(['res1' => ['rightC'], 'res2' => []]); - $permissionModel3->getPermissions($this->user, ['res1', 'res2'])->willReturn(['res1' => ['rightC', 'rightD'], 'res2' => []]); - - return Intersection::spawn([$permissionModel1->reveal(), $permissionModel2->reveal(), $permissionModel3->reveal()]); + $permissionModel1 + ->getPermissions($this->user, ['res1', 'res2']) + ->willReturn(['res1' => ['rightA', 'rightC'], 'res2' => []]); + $permissionModel2 + ->getPermissions($this->user, ['res1', 'res2']) + ->willReturn(['res1' => ['rightC'], 'res2' => []]); + $permissionModel3 + ->getPermissions($this->user, ['res1', 'res2']) + ->willReturn(['res1' => ['rightC', 'rightD'], 'res2' => []]); + + return Intersection::spawn([ + $permissionModel1->reveal(), + $permissionModel2->reveal(), + $permissionModel3->reveal() + ]); } public function testConstruct() @@ -74,7 +84,10 @@ public function testGetPermissions() { $model = $this->createIntersection(); $this->assertEquals(['res1' => []], $model->getPermissions($this->user, ['res1'])); - $this->assertEquals(['res1' => ['rightC'], 'res2' => []], $model->getPermissions($this->user, ['res1', 'res2'])); + $this->assertEquals( + ['res1' => ['rightC'], 'res2' => []], + $model->getPermissions($this->user, ['res1', 'res2']) + ); } public function testGetSupportedRights() diff --git a/test/unit/model/persistence/newsql/NewSqlRdfTest.php b/test/unit/model/persistence/newsql/NewSqlRdfTest.php index a46615baf..c68177781 100644 --- a/test/unit/model/persistence/newsql/NewSqlRdfTest.php +++ b/test/unit/model/persistence/newsql/NewSqlRdfTest.php @@ -33,7 +33,8 @@ class NewSqlRdfTest extends TestCase { public function testAdd() { - $query = 'INSERT INTO statements ( id, modelId, subject, predicate, object, l_language, epoch, author) VALUES ( ?, ? , ? , ? , ? , ? , ?, ?);'; + $query = 'INSERT INTO statements ( id, modelId, subject, predicate, object, l_language, epoch, author) VALUES ' + . '( ?, ? , ? , ? , ? , ? , ?, ?);'; $triple = new \core_kernel_classes_Triple(); $triple->modelid = 22; diff --git a/test/unit/model/persistence/smoothsql/SmoothRdfTest.php b/test/unit/model/persistence/smoothsql/SmoothRdfTest.php index d3ef30e5c..176cce6eb 100644 --- a/test/unit/model/persistence/smoothsql/SmoothRdfTest.php +++ b/test/unit/model/persistence/smoothsql/SmoothRdfTest.php @@ -77,7 +77,8 @@ public function testAdd() $persistence = $this->prophesize('\common_persistence_SqlPersistence'); $persistence->getPlatForm()->willReturn($platform->reveal()); - $query = "INSERT INTO statements ( modelId, subject, predicate, object, l_language, epoch, author) VALUES ( ? , ? , ? , ? , ? , ?, ?);"; + $query = "INSERT INTO statements ( modelId, subject, predicate, object, l_language, epoch, author) VALUES " + . "( ? , ? , ? , ? , ? , ?, ?);"; $triple = new \core_kernel_classes_Triple(); $triple->modelid = 22; @@ -118,7 +119,8 @@ public function testAddWithAuthor() $persistence = $this->prophesize('\common_persistence_SqlPersistence'); $persistence->getPlatForm()->willReturn($platform->reveal()); - $query = "INSERT INTO statements ( modelId, subject, predicate, object, l_language, epoch, author) VALUES ( ? , ? , ? , ? , ? , ?, ?);"; + $query = "INSERT INTO statements ( modelId, subject, predicate, object, l_language, epoch, author) VALUES " + . "( ? , ? , ? , ? , ? , ?, ?);"; $triple = new \core_kernel_classes_Triple(); $triple->modelid = 22; diff --git a/test/unit/oatbox/mutex/LockServiceTest.php b/test/unit/oatbox/mutex/LockServiceTest.php index 3f6d8be19..2fd79fb74 100644 --- a/test/unit/oatbox/mutex/LockServiceTest.php +++ b/test/unit/oatbox/mutex/LockServiceTest.php @@ -44,10 +44,26 @@ public function testLock() $sleep = 3; $this->getInstance(FlockStore::class, $dir); $time = time(); - $pipe1 = popen('php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId1 . ' ' . $sleep . ' FlockStore ' . $dir, 'w'); - $pipe2 = popen('php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId1 . ' ' . $sleep . ' FlockStore ' . $dir, 'w'); - $pipe3 = popen('php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId1 . ' ' . $sleep . ' FlockStore ' . $dir, 'w'); - $pipe4 = popen('php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId2 . ' ' . $sleep . ' FlockStore ' . $dir, 'w'); + $pipe1 = popen( + 'php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId1 . ' ' . $sleep + . ' FlockStore ' . $dir, + 'w' + ); + $pipe2 = popen( + 'php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId1 . ' ' . $sleep + . ' FlockStore ' . $dir, + 'w' + ); + $pipe3 = popen( + 'php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId1 . ' ' . $sleep + . ' FlockStore ' . $dir, + 'w' + ); + $pipe4 = popen( + 'php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId2 . ' ' . $sleep + . ' FlockStore ' . $dir, + 'w' + ); pclose($pipe1); pclose($pipe2); pclose($pipe3); @@ -63,9 +79,18 @@ public function testNoLock() $sleep = 3; $this->getInstance(NoLockStorage::class); $time = time(); - $pipe1 = popen('php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId1 . ' ' . $sleep . ' NoLockStorage', 'w'); - $pipe2 = popen('php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId1 . ' ' . $sleep . ' NoLockStorage', 'w'); - $pipe3 = popen('php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId1 . ' ' . $sleep . ' NoLockStorage', 'w'); + $pipe1 = popen( + 'php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId1 . ' ' . $sleep . ' NoLockStorage', + 'w' + ); + $pipe2 = popen( + 'php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId1 . ' ' . $sleep . ' NoLockStorage', + 'w' + ); + $pipe3 = popen( + 'php ' . __DIR__ . DIRECTORY_SEPARATOR . 'test_action.php ' . $actionId1 . ' ' . $sleep . ' NoLockStorage', + 'w' + ); pclose($pipe1); pclose($pipe2); pclose($pipe3); diff --git a/test/unit/oatbox/service/EnvironmentVariableTest.php b/test/unit/oatbox/service/EnvironmentVariableTest.php index 8719b42d5..c467571e3 100644 --- a/test/unit/oatbox/service/EnvironmentVariableTest.php +++ b/test/unit/oatbox/service/EnvironmentVariableTest.php @@ -55,7 +55,10 @@ public function testConstructorWithNonStringKeyThrowsException() public function testToPhpCode() { - $this->assertSame('new ' . EnvironmentVariable::class . '(' . Utils::toPHPVariableString(self::VAR_NAME) . ')', $this->subject->__toPhpCode()); + $this->assertSame( + 'new ' . EnvironmentVariable::class . '(' . Utils::toPHPVariableString(self::VAR_NAME) . ')', + $this->subject->__toPhpCode() + ); } public function testToString()