diff --git a/SchematicPlugin.php b/SchematicPlugin.php index 7cfb0f96..2c93191b 100644 --- a/SchematicPlugin.php +++ b/SchematicPlugin.php @@ -7,11 +7,11 @@ * * Sync Craft Setups. * - * @author Itmundi - * @copyright Copyright (c) 2015, Itmundi + * @author Nerds & Company + * @copyright Copyright (c) 2015, Nerds & Company * @license MIT * - * @link http://www.itmundi.nl + * @link http://www.nerds.company */ class SchematicPlugin extends BasePlugin { @@ -42,7 +42,7 @@ public function getVersion() */ public function getDeveloper() { - return 'Itmundi'; + return 'Nerds & Company'; } /** @@ -52,6 +52,6 @@ public function getDeveloper() */ public function getDeveloperUrl() { - return 'http://www.itmundi.nl'; + return 'http://www.nerds.company'; } } diff --git a/composer.json b/composer.json index db5be3ca..2f2cc217 100644 --- a/composer.json +++ b/composer.json @@ -3,27 +3,39 @@ "description": "Sync Craft setups", "authors": [ { - "name": "Bart van Gennepg", - "email": "b.vangennep@itmundi.nl", - "homepage": "http://www.itmundi.nl", + "name": "Bart van Gennep", + "email": "b.vangennep@nerds.company", + "homepage": "http://www.nerds.company", "role": "Developer" }, { "name": "Bob Olde Hampsink", - "email": "b.oldehampsink@itmundi.nl", - "homepage": "http://www.itmundi.nl", + "email": "b.oldehampsink@nerds.company", + "homepage": "http://www.nerds.company", "role": "Developer" }, { "name": "Gijs Stegehuis", - "email": "g.stegehuis@itmundi.nl", - "homepage": "http://www.itmundi.nl", + "email": "g.stegehuis@nerds.company", + "homepage": "http://www.nerds.company", "role": "Developer" }, { "name": "Nick Obermeijer", - "email": "n.obermeijer@itmundi.nl", - "homepage": "http://www.itmundi.nl", + "email": "n.obermeijer@nerds.company", + "homepage": "http://www.nerds.company", + "role": "Developer" + }, + { + "name": "Arjan Kleene", + "email": "a.kleene@nerds.company", + "homepage": "http://www.nerds.company", + "role": "Developer" + }, + { + "name": "Niek Schmoller", + "email": "n.schmoller@nerds.company", + "homepage": "http://www.nerds.company", "role": "Developer" } ], diff --git a/consolecommands/SchematicCommand.php b/consolecommands/SchematicCommand.php index 1de69629..a08ab6c6 100644 --- a/consolecommands/SchematicCommand.php +++ b/consolecommands/SchematicCommand.php @@ -7,20 +7,20 @@ * * Sync Craft Setups. * - * @author Itmundi - * @copyright Copyright (c) 2015, Itmundi + * @author Nerds & Company + * @copyright Copyright (c) 2015, Nerds & Company * @license MIT * - * @link http://www.itmundi.nl + * @link http://www.nerds.company */ class SchematicCommand extends BaseCommand { /** * Imports the Craft datamodel. * - * @param string $file yml file containing the schema definition - * @param string $override_file yml file containing the override values - * @param bool $force if set to true items not in the import will be deleted + * @param string $file yml file containing the schema definition + * @param string $override_file yml file containing the override values + * @param bool $force if set to true items not in the import will be deleted */ public function actionImport($file = 'craft/config/schema.yml', $override_file = 'craft/config/override.yml', $force = false) { diff --git a/models/Schematic_DataModel.php b/models/Schematic_DataModel.php index 4cf2a60e..5fd7d9f7 100644 --- a/models/Schematic_DataModel.php +++ b/models/Schematic_DataModel.php @@ -9,11 +9,11 @@ * * Encapsulates data that has been exported via schematic. * - * @author Itmundi - * @copyright Copyright (c) 2015, Itmundi + * @author Nerds & Company + * @copyright Copyright (c) 2015, Nerds & Company * @license MIT * - * @link http://www.itmundi.nl + * @link http://www.nerds.company */ class Schematic_DataModel extends BaseModel { @@ -72,12 +72,14 @@ public static function toYaml(array $data) } /** - * @param string $attribute + * @param string $attribute * @param bool|false $flattenValue - * @param array $default + * @param array $default + * * @return array */ - public function getAttribute($attribute, $flattenValue = false, $default = array()) { + public function getAttribute($attribute, $flattenValue = false, $default = array()) + { $attribute = parent::getAttribute($attribute, $flattenValue); return (!is_null($attribute) ? $attribute : $default); diff --git a/models/Schematic_ResultModel.php b/models/Schematic_ResultModel.php index eda2af77..0104e99d 100644 --- a/models/Schematic_ResultModel.php +++ b/models/Schematic_ResultModel.php @@ -7,11 +7,11 @@ * * Encapsulates the result of an action, including error messages. * - * @author Itmundi - * @copyright Copyright (c) 2015, Itmundi + * @author Nerds & Company + * @copyright Copyright (c) 2015, Nerds & Company * @license MIT * - * @link http://www.itmundi.nl + * @link http://www.nerds.company */ class Schematic_ResultModel extends BaseModel { diff --git a/services/SchematicService.php b/services/SchematicService.php index 9737d2e4..8311e855 100644 --- a/services/SchematicService.php +++ b/services/SchematicService.php @@ -7,11 +7,11 @@ * * Sync Craft Setups. * - * @author Itmundi - * @copyright Copyright (c) 2015, Itmundi + * @author Nerds & Company + * @copyright Copyright (c) 2015, Nerds & Company * @license MIT * - * @link http://www.itmundi.nl + * @link http://www.nerds.company */ class SchematicService extends BaseApplicationComponent { @@ -19,10 +19,12 @@ class SchematicService extends BaseApplicationComponent const SCHEMATIC_METHOD_EXPORT = 'export'; /** - * Returns data from import model or default - * @param array $data + * Returns data from import model or default. + * + * @param array $data * @param string $handle - * @param array $default + * @param array $default + * * @return array */ private function getPluginData(array $data, $handle, array $default = array()) @@ -32,9 +34,11 @@ private function getPluginData(array $data, $handle, array $default = array()) /** * Import from Yaml file. + * * @param string $file * @param string $override - * @param bool $force if set to true items not included in import will be deleted + * @param bool $force if set to true items not included in import will be deleted + * * @return Schematic_ResultModel */ public function importFromYaml($file, $override = null, $force = false) @@ -48,8 +52,10 @@ public function importFromYaml($file, $override = null, $force = false) /** * Export to Yaml file. + * * @param string $file - * @param bool $autoCreate + * @param bool $autoCreate + * * @return Schematic_ResultModel */ public function exportToYaml($file, $autoCreate = true) @@ -67,8 +73,10 @@ public function exportToYaml($file, $autoCreate = true) /** * Import data model. + * * @param Schematic_DataModel $model * @param bool $force if set to true items not in the import will be deleted + * * @return Schematic_ResultModel */ private function importDataModel(Schematic_DataModel $model, $force) @@ -99,13 +107,15 @@ private function importDataModel(Schematic_DataModel $model, $force) } /** - * Handles importing - * @param Schematic_ResultModel $result - * @param array $data + * Handles importing. + * + * @param Schematic_ResultModel $result + * @param array $data * @param array|Schematic_AbstractService[] $services * @param $force */ - private function doImport(Schematic_ResultModel $result, array $data, $services, $force) { + private function doImport(Schematic_ResultModel $result, array $data, $services, $force) + { foreach ($services as $handle => $service) { if (is_array($service)) { $this->doImport($result, $data, $service, $force); @@ -147,7 +157,8 @@ private function exportDataModel() } /** - * Handles exporting + * Handles exporting. + * * @param array $services * @param array $data */ diff --git a/services/Schematic_AbstractService.php b/services/Schematic_AbstractService.php index f4046ca3..73cac65f 100644 --- a/services/Schematic_AbstractService.php +++ b/services/Schematic_AbstractService.php @@ -5,11 +5,11 @@ /** * Schematic Base Service for some easy access methods. * - * @author Itmundi - * @copyright Copyright (c) 2015, Itmundi + * @author Nerds & Company + * @copyright Copyright (c) 2015, Nerds & Company * @license MIT * - * @link http://www.itmundi.nl + * @link http://www.nerds.company */ abstract class Schematic_AbstractService extends BaseApplicationComponent { diff --git a/services/Schematic_AssetsService.php b/services/Schematic_AssetsService.php index eeaba2e3..1328a71d 100644 --- a/services/Schematic_AssetsService.php +++ b/services/Schematic_AssetsService.php @@ -7,11 +7,11 @@ * * Sync Craft Setups. * - * @author Itmundi - * @copyright Copyright (c) 2015, Itmundi + * @author Nerds & Company + * @copyright Copyright (c) 2015, Nerds & Company * @license MIT * - * @link http://www.itmundi.nl + * @link http://www.nerds.company */ class Schematic_AssetsService extends Schematic_AbstractService { diff --git a/services/Schematic_FieldsService.php b/services/Schematic_FieldsService.php index 16cee184..71e581c5 100644 --- a/services/Schematic_FieldsService.php +++ b/services/Schematic_FieldsService.php @@ -7,11 +7,11 @@ * * Sync Craft Setups. * - * @author Itmundi - * @copyright Copyright (c) 2015, Itmundi + * @author Nerds & Company + * @copyright Copyright (c) 2015, Nerds & Company * @license MIT * - * @link http://www.itmundi.nl + * @link http://www.nerds.company */ class Schematic_FieldsService extends Schematic_AbstractService { @@ -94,7 +94,7 @@ public function export(array $groups = array()) * Get field definition. * * @param FieldModel $field - * @param bool $includeContext + * @param bool $includeContext * * @return array */ @@ -145,6 +145,7 @@ private function getSourceHandles($sourcesWithIds) /** * @param string $source with id + * * @return string source with handle */ private function getSourceHandle($source) @@ -163,9 +164,10 @@ private function getSourceHandle($source) break; } if ($sourceObject) { - $source = $sourceType . ':' . $sourceObject->handle; + $source = $sourceType.':'.$sourceObject->handle; } } + return $source; } @@ -310,7 +312,7 @@ private function validateFieldModel(FieldModel $field) /** * Import field group fields. * - * @param array $fieldDefinitions + * @param array $fieldDefinitions * @param FieldGroupModel $group * * @throws \Exception @@ -330,7 +332,7 @@ private function importFields(array $fieldDefinitions, FieldGroupModel $group) * Unset group and field data else $force flag will delete it. * * @param string $name - * @param array $definitions + * @param array $definitions */ private function unsetData($name, array $definitions) { @@ -346,7 +348,7 @@ private function unsetData($name, array $definitions) * Attempt to import fields. * * @param array $groupDefinitions - * @param bool $force if set to true items not in the import will be deleted + * @param bool $force if set to true items not in the import will be deleted * * @return Schematic_ResultModel */ @@ -387,10 +389,10 @@ public function import(array $groupDefinitions, $force = false) /** * Populate blocktype. * - * @param FieldModel $field + * @param FieldModel $field * @param MatrixBlockTypeModel $blockType - * @param array $blockTypeDef - * @param string $blockTypeHandle + * @param array $blockTypeDef + * @param string $blockTypeHandle */ private function populateBlockType(FieldModel $field, MatrixBlockTypeModel $blockType, array $blockTypeDef, $blockTypeHandle) { @@ -421,9 +423,9 @@ private function populateBlockType(FieldModel $field, MatrixBlockTypeModel $bloc /** * Populate field. * - * @param array $fieldDefinition - * @param FieldModel $field - * @param string $fieldHandle + * @param array $fieldDefinition + * @param FieldModel $field + * @param string $fieldHandle * @param FieldGroupModel $group */ private function populateField( @@ -431,8 +433,7 @@ private function populateField( FieldModel $field, $fieldHandle, FieldGroupModel $group = null - ) - { + ) { $field->name = $fieldDefinition['name']; $field->handle = $fieldHandle; $field->required = $fieldDefinition['required']; @@ -484,11 +485,13 @@ private function getSourceIds($sourcesWithHandle) foreach ($sourcesWithHandle as $sourceWithHandle) { $sourcesWithIds[] = $this->getSourceId($sourceWithHandle); } + return $sourcesWithIds; } /** * @param $source + * * @return string */ private function getSourceId($source) @@ -512,7 +515,7 @@ private function getSourceId($source) $sourceObject = craft()->sections->getSectionByHandle($source); } if ($sourceObject && isset($sourceType)) { - $source = $sourceType . ':' . $sourceObject->id; + $source = $sourceType.':'.$sourceObject->id; } return $source; @@ -521,7 +524,7 @@ private function getSourceId($source) /** * Get blocktypes. * - * @param array $fieldDefinition + * @param array $fieldDefinition * @param FieldModel $field * * @return mixed diff --git a/services/Schematic_GlobalsService.php b/services/Schematic_GlobalsService.php index 95980a41..eec97d38 100644 --- a/services/Schematic_GlobalsService.php +++ b/services/Schematic_GlobalsService.php @@ -7,11 +7,11 @@ * * Sync Craft Setups. * - * @author Itmundi - * @copyright Copyright (c) 2015, Itmundi + * @author Nerds & Company + * @copyright Copyright (c) 2015, Nerds & Company * @license MIT * - * @link http://www.itmundi.nl + * @link http://www.nerds.company */ class Schematic_GlobalsService extends Schematic_AbstractService { diff --git a/services/Schematic_PluginsService.php b/services/Schematic_PluginsService.php index 98f794b2..cf82b113 100644 --- a/services/Schematic_PluginsService.php +++ b/services/Schematic_PluginsService.php @@ -7,11 +7,11 @@ * * Sync Craft Setups. * - * @author Itmundi - * @copyright Copyright (c) 2015, Itmundi + * @author Nerds & Company + * @copyright Copyright (c) 2015, Nerds & Company * @license MIT * - * @link http://www.itmundi.nl + * @link http://www.nerds.company */ class Schematic_PluginsService extends Schematic_AbstractService { diff --git a/services/Schematic_SectionsService.php b/services/Schematic_SectionsService.php index 6342b0fd..03ef687c 100644 --- a/services/Schematic_SectionsService.php +++ b/services/Schematic_SectionsService.php @@ -7,11 +7,11 @@ * * Sync Craft Setups. * - * @author Itmundi - * @copyright Copyright (c) 2015, Itmundi + * @author Nerds & Company + * @copyright Copyright (c) 2015, Nerds & Company * @license MIT * - * @link http://www.itmundi.nl + * @link http://www.nerds.company */ class Schematic_SectionsService extends Schematic_AbstractService { diff --git a/services/Schematic_UserGroupsService.php b/services/Schematic_UserGroupsService.php index d0737014..8d38c226 100644 --- a/services/Schematic_UserGroupsService.php +++ b/services/Schematic_UserGroupsService.php @@ -7,11 +7,11 @@ * * Sync Craft Setups. * - * @author Itmundi - * @copyright Copyright (c) 2015, Itmundi + * @author Nerds & Company + * @copyright Copyright (c) 2015, Nerds & Company * @license MIT * - * @link http://www.itmundi.nl + * @link http://www.nerds.company */ class Schematic_UserGroupsService extends Schematic_AbstractService { @@ -129,7 +129,7 @@ private function getGroupPermissionDefinitions($group) $groupPermissions = $this->getUserPermissionsService()->getPermissionsByGroupId($group->id); foreach ($groupPermissions as $permission) { - if(array_key_exists($permission, $this->mappedPermissions)){ + if (array_key_exists($permission, $this->mappedPermissions)) { $permission = $this->mappedPermissions[$permission]; $permissionDefinitions[] = $this->getPermissionDefinition($permission); } @@ -140,7 +140,8 @@ private function getGroupPermissionDefinitions($group) /** * Get a mapping of all permissions from lowercase to camelcase - * savePermissions only accepts camelcase + * savePermissions only accepts camelcase. + * * @return array */ private function getAllMappedPermissions() @@ -149,11 +150,13 @@ private function getAllMappedPermissions() foreach ($this->getUserPermissionsService()->getAllPermissions() as $permissions) { $mappedPermissions = array_merge($mappedPermissions, $this->getMappedPermissions($permissions)); } + return $mappedPermissions; } /** * @param array $permissions + * * @return array */ private function getMappedPermissions(array $permissions) @@ -185,6 +188,7 @@ private function getPermissionDefinition($permission) } else { $permission = $this->mapPermissionSource($this->sectionsById, $permission, true); } + return $permission; } @@ -197,7 +201,7 @@ private function getPermissionDefinition($permission) * Import usergroups. * * @param array $groupDefinitions - * @param bool $force if set to true items not in the import will be deleted + * @param bool $force if set to true items not in the import will be deleted * * @return Schematic_ResultModel */ @@ -270,6 +274,7 @@ private function getPermission($permissionDefinition) } else { $permissionDefinition = $this->mapPermissionSource($this->sectionsByHandle, $permissionDefinition, false); } + return $permissionDefinition; } @@ -278,9 +283,10 @@ private function getPermission($permissionDefinition) //============================================================================================================== /** - * @param BaseElementModel[] $mapping AssetSources or Sections - * @param string $permission - * @param bool $export is it an export or import + * @param BaseElementModel[] $mapping AssetSources or Sections + * @param string $permission + * @param bool $export is it an export or import + * * @return string mapped permission */ private function mapPermissionSource(array $mapping, $permission, $export) @@ -295,9 +301,10 @@ private function mapPermissionSource(array $mapping, $permission, $export) } if ($source) { - $permission = $permissionName . ':' . ($export ? $source->handle : $source->id); + $permission = $permissionName.':'.($export ? $source->handle : $source->id); } } + return $permission; } } diff --git a/services/Schematic_UsersService.php b/services/Schematic_UsersService.php index 5ca9b880..7cd496fb 100644 --- a/services/Schematic_UsersService.php +++ b/services/Schematic_UsersService.php @@ -7,11 +7,11 @@ * * Sync Craft Setups. * - * @author Itmundi - * @copyright Copyright (c) 2015, Itmundi + * @author Nerds & Company + * @copyright Copyright (c) 2015, Nerds & Company * @license MIT * - * @link http://www.itmundi.nl + * @link http://www.nerds.company */ class Schematic_UsersService extends Schematic_AbstractService { @@ -45,7 +45,7 @@ private function getUsersDefinition(UserModel $user) * Attempt to import user settings. * * @param array $user_settings - * @param bool $force If set to true user settings not included in the import will be deleted + * @param bool $force If set to true user settings not included in the import will be deleted * * @return Schematic_ResultModel */ @@ -54,16 +54,16 @@ public function import(array $user_settings, $force = true) // always delete existing fieldlayout first craft()->fields->deleteLayoutsByType(ElementType::User); - if(isset($user_settings['fieldLayout'])) { + if (isset($user_settings['fieldLayout'])) { $fieldLayoutDefinition = (array) $user_settings['fieldLayout']; } else { $fieldLayoutDefinition = array(); } $fieldLayout = craft()->schematic_fields->getFieldLayout($fieldLayoutDefinition); - $fieldLayout->type = ElementType::User; + $fieldLayout->type = ElementType::User; - if (!craft()->fields->saveLayout($fieldLayout)) { // Save fieldlayout via craft + if (!craft()->fields->saveLayout($fieldLayout)) { // Save fieldlayout via craft $this->addErrors($fieldLayout->getAllErrors()); } diff --git a/tests/Schematic_PluginsServiceTest.php b/tests/Schematic_PluginsServiceTest.php index 16aebbe5..1269a485 100644 --- a/tests/Schematic_PluginsServiceTest.php +++ b/tests/Schematic_PluginsServiceTest.php @@ -7,11 +7,11 @@ /** * Class Schematic_PluginsServiceTest. * - * @author Itmundi - * @copyright Copyright (c) 2015, Itmundi + * @author Nerds & Company + * @copyright Copyright (c) 2015, Nerds & Company * @license MIT * - * @link http://www.itmundi.nl + * @link http://www.nerds.company * * @coversDefaultClass Craft\Schematic_PluginsService * @covers ::__construct diff --git a/tests/Schematic_SchematicServiceTest.php b/tests/Schematic_SchematicServiceTest.php index f791fd92..580ce7de 100644 --- a/tests/Schematic_SchematicServiceTest.php +++ b/tests/Schematic_SchematicServiceTest.php @@ -8,11 +8,11 @@ /** * Class Schematic_UsersServiceTest. * - * @author Itmundi - * @copyright Copyright (c) 2015, Itmundi + * @author Nerds & Company + * @copyright Copyright (c) 2015, Nerds & Company * @license MIT * - * @link http://www.itmundi.nl + * @link http://www.nerds.company * * @coversDefaultClass Craft\SchematicService * @covers :: @@ -24,7 +24,6 @@ class Schematic_SchematicServiceTest extends BaseTest */ private $schematicService; - /** * {@inheritdoc} */ @@ -59,12 +58,12 @@ public static function setUpBeforeClass() */ private function getYamlTestFile() { - return __DIR__ . '/data/test_schema.yml'; + return __DIR__.'/data/test_schema.yml'; } /** * @param string $handle - * @param Mock $mock + * @param Mock $mock */ private function setCraftComponent($handle, Mock $mock) { @@ -86,13 +85,15 @@ public function getMockFieldsService() } /** - * @param string $class - * @param string $method + * @param string $class + * @param string $method * @param Invocation $invocation - * @param mixed $returnValue + * @param mixed $returnValue + * * @return Mock */ - public function getDynamicallyMockedService($class, $method, Invocation $invocation, $returnValue) { + public function getDynamicallyMockedService($class, $method, Invocation $invocation, $returnValue) + { $mock = $this->getMockBuilder($class)->disableOriginalConstructor()->getMock(); $mock->expects($invocation)->method($method)->willReturn($returnValue); @@ -141,7 +142,8 @@ public function getMockResultModel() } /** - * Creates mock for service + * Creates mock for service. + * * @param string $service * @param string $handle */ @@ -189,7 +191,7 @@ public function getMockPluginsService() } /** - * Mock all required services + * Mock all required services. */ private function mockServices() { @@ -206,17 +208,19 @@ private function mockServices() } /** - * Test import from Yaml + * Test import from Yaml. + * * @covers ::importFromYaml */ public function testImportFromYamlWithForce() { - $results = $this->schematicService->importFromYaml($this->getYamlTestFile(), null, true); - $this->assertFalse($results->hasErrors()); + $results = $this->schematicService->importFromYaml($this->getYamlTestFile(), null, true); + $this->assertFalse($results->hasErrors()); } /** * @param $service + * * @return Mock */ private function getMockAllGroupsMethodService($service) @@ -225,7 +229,7 @@ private function getMockAllGroupsMethodService($service) } /** - * Prep export services + * Prep export services. */ private function prepExportMockServices() { @@ -246,7 +250,8 @@ private function prepExportMockServices() } /** - * Test export to yml + * Test export to yml. + * * @covers ::exportToYaml */ public function testExportFromYaml() @@ -258,7 +263,8 @@ public function testExportFromYaml() } /** - * Test export to yml with error writing to file + * Test export to yml with error writing to file. + * * @covers ::exportToYaml */ public function testExportFromYamlWithFileError() diff --git a/tests/Schematic_UserGroupsServiceTest.php b/tests/Schematic_UserGroupsServiceTest.php index 1cb5cf68..7e9fa976 100644 --- a/tests/Schematic_UserGroupsServiceTest.php +++ b/tests/Schematic_UserGroupsServiceTest.php @@ -5,13 +5,13 @@ use PHPUnit_Framework_MockObject_MockObject as MockObject; /** - * Class Schematic_PluginsServiceTest + * Class Schematic_PluginsServiceTest. * - * @author Itmundi - * @copyright Copyright (c) 2015, Itmundi + * @author Nerds & Company + * @copyright Copyright (c) 2015, Nerds & Company * @license MIT * - * @link http://www.itmundi.nl + * @link http://www.nerds.company * * @coversDefaultClass Craft\Schematic_UserGroupsService * @covers ::__construct @@ -19,7 +19,6 @@ */ class Schematic_UserGroupsServiceTest extends BaseTest { - /** * {@inheritdoc} */ @@ -41,8 +40,8 @@ public static function setUpBeforeClass() * @dataProvider provideValidUserGroups * * @param UserGroupModel[] $groups - * @param string[] $groupPermissions - * @param array $expectedResult + * @param string[] $groupPermissions + * @param array $expectedResult */ public function testSuccessfulExport(array $groups, array $groupPermissions, array $expectedResult = array()) { @@ -99,7 +98,7 @@ public function testImportWhereSavingGroupFails(array $groupDefinitions) $import = $schematicUserGroupsService->import($groupDefinitions); $this->assertTrue($import instanceof Schematic_ResultModel); - if(!empty($groupDefinitions)){ + if (!empty($groupDefinitions)) { $this->assertTrue($import->hasErrors()); } } @@ -152,8 +151,8 @@ public function provideValidUserGroups() 'groupHandle1' => array( 'name' => 'groupName1', 'permissions' => array(), - ) - ) + ), + ), ), 'multiple groups without permissions' => array( 'userGroups' => array( @@ -172,8 +171,8 @@ public function provideValidUserGroups() 'groupHandle2' => array( 'name' => 'groupName2', 'permissions' => array(), - ) - ) + ), + ), ), 'single group with permissions' => array( 'userGroups' => array( @@ -199,9 +198,9 @@ public function provideValidUserGroups() 'editGlobalSet:globalSetHandle1', 'viewAssetSource:assetSourceHandle1', ), - ) - ) - ) + ), + ), + ), ); } @@ -219,8 +218,8 @@ public function provideValidUserGroupDefinitions() 'groupHandle1' => array( 'name' => 'groupName1', 'permissions' => array(), - ) - ) + ), + ), ), 'single group with permissions' => array( 'groupDefinitions' => array( @@ -233,8 +232,8 @@ public function provideValidUserGroupDefinitions() 'editGlobalSet:globalSetHandle1', 'viewAssetSource:assetSourceHandle1', ), - ) - ) + ), + ), ), ); } @@ -245,6 +244,7 @@ public function provideValidUserGroupDefinitions() /** * @param string $groupId + * * @return MockObject|UserGroupModel */ private function getMockUserGroup($groupId) @@ -257,14 +257,14 @@ private function getMockUserGroup($groupId) ->method('__get') ->willReturnMap(array( array('id', $groupId), - array('handle', 'groupHandle' . $groupId), - array('name', 'groupName' . $groupId), + array('handle', 'groupHandle'.$groupId), + array('name', 'groupName'.$groupId), )); $mockUserGroup->expects($this->any()) ->method('getAllErrors') ->willReturn(array( - 'ohnoes' => 'horrible error' + 'ohnoes' => 'horrible error', )); return $mockUserGroup; @@ -272,6 +272,7 @@ private function getMockUserGroup($groupId) /** * @param $indexBy + * * @return MockObject|SectionsService */ private function setMockSectionsService($indexBy) @@ -292,7 +293,8 @@ private function setMockSectionsService($indexBy) /** * @param string $indexBy - * @param int $count + * @param int $count + * * @return MockObject[]|SectionModel[] */ private function getMockSections($indexBy, $count) @@ -307,18 +309,20 @@ private function getMockSections($indexBy, $count) $mockSection->expects($this->any()) ->method('__get') ->willReturnMap(array( - array('handle', 'sectionHandle' . $x), + array('handle', 'sectionHandle'.$x), array('id', $x), - array('name', 'sectionName' . $x) + array('name', 'sectionName'.$x), )); - $mockSections[$keyPrefix . $x] = $mockSection; + $mockSections[$keyPrefix.$x] = $mockSection; } + return $mockSections; } /** * @param string $indexBy + * * @return MockObject|AssetSourcesService */ private function setMockAssetSourcesService($indexBy) @@ -339,7 +343,8 @@ private function setMockAssetSourcesService($indexBy) /** * @param string $indexBy - * @param int $count + * @param int $count + * * @return MockObject[]|AssetSourceModel[] */ private function getMockAssetSources($indexBy, $count) @@ -354,18 +359,20 @@ private function getMockAssetSources($indexBy, $count) $mockAssetSource->expects($this->any()) ->method('__get') ->willReturnMap(array( - array('handle', 'assetSourceHandle' . $x), + array('handle', 'assetSourceHandle'.$x), array('id', $x), - array('name', 'assetSourceName' . $x) + array('name', 'assetSourceName'.$x), )); - $mockAssetSources[$keyPrefix . $x] = $mockAssetSource; + $mockAssetSources[$keyPrefix.$x] = $mockAssetSource; } + return $mockAssetSources; } /** * @param string $indexBy + * * @return MockObject|AssetSourcesService */ private function setMockGlobalsService($indexBy) @@ -386,7 +393,8 @@ private function setMockGlobalsService($indexBy) /** * @param string $indexBy - * @param int $count + * @param int $count + * * @return MockObject[]|GlobalSetModel[] */ private function getMockGlobalSets($indexBy, $count) @@ -401,18 +409,20 @@ private function getMockGlobalSets($indexBy, $count) $mockGlobalSet->expects($this->any()) ->method('__get') ->willReturnMap(array( - array('handle', 'globalSetHandle' . $x), + array('handle', 'globalSetHandle'.$x), array('id', $x), - array('name', 'globalSetName' . $x) + array('name', 'globalSetName'.$x), )); - $mockGlobalSets[$keyPrefix . $x] = $mockGlobalSet; + $mockGlobalSets[$keyPrefix.$x] = $mockGlobalSet; } + return $mockGlobalSets; } /** * @param bool $success + * * @return UserGroupsService|MockObject */ private function setMockUserGroupsService($success = true) @@ -438,20 +448,23 @@ private function setMockUserGroupsService($success = true) /** * @param int $count + * * @return array */ private function getMockUserGroups($count) { $mockUserGroups = array(); for ($x = 0; $x <= $count; $x++) { - $mockUserGroups['groupHandle' . $x] = $this->getMockUserGroup($x);; + $mockUserGroups['groupHandle'.$x] = $this->getMockUserGroup($x); } + return $mockUserGroups; } /** * @param array $permissions - * @param bool $success + * @param bool $success + * * @return UserPermissionsService|MockObject */ private function setMockUserPermissionsService(array $permissions = array(), $success = true) @@ -483,29 +496,29 @@ private function setMockUserPermissionsService(array $permissions = array(), $su private function getAllPermissionsExample() { return array( - "General" => array( - "accessSiteWhenSystemIsOff" => array( - "nested" => array( - "accessCpWhenSystemIsOff" => array(), - "performUpdates" => array(), - "accessPlugin-PluginName1" => array(), - "accessPlugin-PluginName2" => array(), - ) - ) + 'General' => array( + 'accessSiteWhenSystemIsOff' => array( + 'nested' => array( + 'accessCpWhenSystemIsOff' => array(), + 'performUpdates' => array(), + 'accessPlugin-PluginName1' => array(), + 'accessPlugin-PluginName2' => array(), + ), + ), ), - "Users" => array( - "editUsers" => array( - "nested" => array( - "registerUsers" => array(), - "assignUserPermissions" => array(), - "administrateUsers" => array( - "nested" => array( - "changeUserEmails" => array(), - ) + 'Users' => array( + 'editUsers' => array( + 'nested' => array( + 'registerUsers' => array(), + 'assignUserPermissions' => array(), + 'administrateUsers' => array( + 'nested' => array( + 'changeUserEmails' => array(), + ), ), - "deleteUsers" => array(), - ) - ) + 'deleteUsers' => array(), + ), + ), ), 'Section - 1' => array( 'editEntries:1' => array( @@ -515,10 +528,10 @@ private function getAllPermissionsExample() 'nested' => array( 'publishPeerEntryDrafts:1' => array(), 'deletePeerEntryDrafts:1' => array(), - ) + ), ), - ) - ) + ), + ), ), 'Section - 2' => array( 'editEntries:2' => array( @@ -528,10 +541,10 @@ private function getAllPermissionsExample() 'nested' => array( 'publishPeerEntryDrafts:2' => array(), 'deletePeerEntryDrafts:2' => array(), - ) + ), ), - ) - ) + ), + ), ), 'GlobalSet - 1' => array( 'editGlobalSet:1' => array(), @@ -541,10 +554,10 @@ private function getAllPermissionsExample() 'nested' => array( 'uploadToAssetSource:1' => array(), 'createSubfoldersInAssetSource:1' => array(), - 'removeFromAssetSource:1' => array() - ) - ) - ) + 'removeFromAssetSource:1' => array(), + ), + ), + ), ); } } diff --git a/tests/Schematic_UsersServiceTest.php b/tests/Schematic_UsersServiceTest.php index a42aba35..e1625c2b 100644 --- a/tests/Schematic_UsersServiceTest.php +++ b/tests/Schematic_UsersServiceTest.php @@ -7,11 +7,11 @@ /** * Class Schematic_UsersServiceTest. * - * @author Itmundi - * @copyright Copyright (c) 2015, Itmundi + * @author Nerds & Company + * @copyright Copyright (c) 2015, Nerds & Company * @license MIT * - * @link http://www.itmundi.nl + * @link http://www.nerds.company * * @coversDefaultClass Craft\Schematic_UsersService * @covers ::__construct @@ -94,7 +94,8 @@ public function getMockFieldsService() } /** - * Test users service export + * Test users service export. + * * @covers ::export */ public function testUsersServiceExport() @@ -121,6 +122,7 @@ public function testUsersServiceExport() /** * @param bool $safeLayout * @param bool $deleteLayoutsByType + * * @return FieldsService|Mock */ private function getMockFieldServiceForImport($safeLayout = true, $deleteLayoutsByType = true) @@ -134,14 +136,15 @@ private function getMockFieldServiceForImport($safeLayout = true, $deleteLayouts /** * @param bool $errors + * * @return Schematic_FieldsService|Mock */ private function getMockSchematicFieldServiceForImport($errors = false) { $mockFieldLayout = $this->getMockFieldLayout(); - if($errors) { + if ($errors) { $mockFieldLayout->expects($this->exactly(1))->method('getAllErrors')->willReturn(array( - 'errors' => array('error 1', 'error 2', 'error 3') + 'errors' => array('error 1', 'error 2', 'error 3'), )); } @@ -152,7 +155,8 @@ private function getMockSchematicFieldServiceForImport($errors = false) } /** - * Test users service import + * Test users service import. + * * @covers ::import */ public function testUsersServiceImportWithForce() @@ -169,7 +173,8 @@ public function testUsersServiceImportWithForce() } /** - * Test users service import + * Test users service import. + * * @covers ::import */ public function testUsersServiceImportWithoutFieldLayout() @@ -186,7 +191,8 @@ public function testUsersServiceImportWithoutFieldLayout() } /** - * Test users service import + * Test users service import. + * * @covers ::import */ public function testUsersServiceImportWithImportError()