Skip to content

Commit

Permalink
Merge pull request #125 from nerds-and-company/phpcs_fixes
Browse files Browse the repository at this point in the history
PHPCS fixes
  • Loading branch information
Bob Olde Hampsink committed Apr 24, 2018
2 parents a75fe8d + 11b20c7 commit 9d06950
Show file tree
Hide file tree
Showing 37 changed files with 99 additions and 19 deletions.
1 change: 1 addition & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<description>Coding standard for schematic</description>

<file>src/</file>
<file>tests/</file>

<arg name="colors"/>
<arg name="extensions" value="php"/>
Expand Down
6 changes: 5 additions & 1 deletion src/Converters/Fields/Matrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ public function saveRecord(Model $record, array $definition): bool

if (parent::saveRecord($record, $definition)) {
if (array_key_exists('blockTypes', $definition)) {
Craft::$app->controller->module->modelMapper->import($definition['blockTypes'], $record->getBlockTypes(), ['fieldId' => $record->id]);
Craft::$app->controller->module->modelMapper->import(
$definition['blockTypes'],
$record->getBlockTypes(),
['fieldId' => $record->id]
);
}

return true;
Expand Down
6 changes: 5 additions & 1 deletion src/Converters/Models/Section.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ public function getRecordDefinition(Model $record): array
public function saveRecord(Model $record, array $definition): bool
{
if (Craft::$app->sections->saveSection($record)) {
Craft::$app->controller->module->modelMapper->import($definition['entryTypes'], $record->getEntryTypes(), ['sectionId' => $record->id]);
Craft::$app->controller->module->modelMapper->import(
$definition['entryTypes'],
$record->getEntryTypes(),
['sectionId' => $record->id]
);

return true;
}
Expand Down
1 change: 1 addition & 0 deletions tests/_support/Helper/Unit.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Unit extends Module
* Mock craft Mappers.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*
* @param TestCase $test
*/
Expand Down
1 change: 1 addition & 0 deletions tests/_support/UnitTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
* phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
*/
class UnitTester extends \Codeception\Actor
{
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/Converters/Base/FieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class FieldTest extends Unit
* Set the converter.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down Expand Up @@ -185,7 +186,7 @@ private function getMockFieldGroup(int $groupId)
{
$mockGroup = $this->getMockBuilder(FieldGroup::class)
->disableOriginalConstructor()
->getmock();
->getMock();

$mockGroup->id = $groupId;
$mockGroup->name = 'fieldGroup'.$groupId;
Expand Down
1 change: 1 addition & 0 deletions tests/unit/Converters/Base/VolumeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class VolumeTest extends Unit
* Set the converter.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down
10 changes: 9 additions & 1 deletion tests/unit/Converters/Elements/GlobalSetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class GlobalSetsTest extends Unit
* Set the converter.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down Expand Up @@ -164,7 +165,14 @@ private function getMockGlobalSetDefinition(GlobalSetElement $mockGlobalSet)
private function getMockGlobalSet(int $setId, string $siteHandle = 'default')
{
$mockSet = $this->getMockBuilder(GlobalSetElement::class)
->setMethods(['__isset', 'getSite', 'getFieldLayout', 'fieldByHandle', 'getBehavior', 'behaviors'])
->setMethods([
'__isset',
'getSite',
'getFieldLayout',
'fieldByHandle',
'getBehavior',
'behaviors',
])
->disableOriginalConstructor()
->getMock();

Expand Down
1 change: 1 addition & 0 deletions tests/unit/Converters/Fields/AssetsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class AssetsTest extends Unit
* Set the converter.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/Converters/Fields/MatrixTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class MatrixTest extends Unit
* Set the converter.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down Expand Up @@ -70,7 +71,9 @@ public function testSaveRecord(MatrixField $matrix, array $definition, bool $val

Craft::$app->controller->module->modelMapper->expects($this->exactly($valid ? 1 : 0))
->method('import')
->with($definition['blockTypes'], $matrix->getBlockTypes(), ['fieldId' => $matrix->id])
->with($definition['blockTypes'], $matrix->getBlockTypes(), [
'fieldId' => $matrix->id,
])
->willReturn($matrix->getBlockTypes());

$result = $this->converter->saveRecord($matrix, $definition);
Expand Down
1 change: 1 addition & 0 deletions tests/unit/Converters/Models/AssetTransformTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class AssetTransformTest extends Unit
* Set the converter.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down
1 change: 1 addition & 0 deletions tests/unit/Converters/Models/CategoryGroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class CategoryGroupTest extends Unit
* Set the converter.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down
1 change: 1 addition & 0 deletions tests/unit/Converters/Models/EntryTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class EntryTypeTest extends Unit
* Set the converter.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down
8 changes: 6 additions & 2 deletions tests/unit/Converters/Models/MatrixBlockTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class MatrixBlockTypeTest extends Unit
* Set the converter.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down Expand Up @@ -63,8 +64,11 @@ public function testGetRecordDefinition(MatrixBlockTypeModel $blockType, array $
* @param array $definition
* @param array $defaultAttributes
*/
public function testSetRecordAttributes(MatrixBlockTypeModel $blockType, array $definition, array $defaultAttributes)
{
public function testSetRecordAttributes(
MatrixBlockTypeModel $blockType,
array $definition,
array $defaultAttributes
) {
$newMatrixBlockType = $this->getMockBuilder(MatrixBlockTypeModel::class)
->setMethods(['setFieldLayout'])
->getMock();
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/Converters/Models/SectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class SectionTest extends Unit
* Set the converter.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down Expand Up @@ -72,7 +73,9 @@ public function testSaveRecord(SectionModel $section, array $definition, bool $v

Craft::$app->controller->module->modelMapper->expects($this->exactly($valid ? 1 : 0))
->method('import')
->with($definition['entryTypes'], $section->getEntryTypes(), ['sectionId' => $section->id])
->with($definition['entryTypes'], $section->getEntryTypes(), [
'sectionId' => $section->id,
])
->willReturn($section->getEntryTypes());

$result = $this->converter->saveRecord($section, $definition);
Expand Down
1 change: 1 addition & 0 deletions tests/unit/Converters/Models/SiteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class SiteTest extends Unit
* Set the converter.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down
1 change: 1 addition & 0 deletions tests/unit/Converters/Models/TagGroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class TagGroupTest extends Unit
* Set the converter.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down
18 changes: 14 additions & 4 deletions tests/unit/Converters/Models/UserGroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class UserGroupTest extends Unit
* Set the converter.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand All @@ -48,8 +49,12 @@ protected function _before()
* @param array $groupPermissions
* @param array $allPermissions
*/
public function testGetRecordDefinition(UserGroupModel $group, array $definition, array $groupPermissions, array $allPermissions)
{
public function testGetRecordDefinition(
UserGroupModel $group,
array $definition,
array $groupPermissions,
array $allPermissions
) {
Craft::$app->userPermissions->expects($this->exactly(1))
->method('getPermissionsByGroupId')
->with($group->id)
Expand Down Expand Up @@ -90,8 +95,13 @@ public function testGetRecordDefinition(UserGroupModel $group, array $definition
* @param array $allPermissions
* @param bool $valid
*/
public function testSaveRecord(UserGroupModel $group, array $definition, array $groupPermissions, array $allPermissions, bool $valid)
{
public function testSaveRecord(
UserGroupModel $group,
array $definition,
array $groupPermissions,
array $allPermissions,
bool $valid
) {
Craft::$app->userGroups->expects($this->exactly(1))
->method('saveGroup')
->with($group)
Expand Down
1 change: 1 addition & 0 deletions tests/unit/DataTypes/AssetTransformDataTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class AssetTransformDataTypeTest extends Unit
* Set the dataType.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down
1 change: 1 addition & 0 deletions tests/unit/DataTypes/CategoryGroupDataTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class CategoryGroupDataTypeTest extends Unit
* Set the dataType.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down
1 change: 1 addition & 0 deletions tests/unit/DataTypes/ElementIndexDataTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ElementIndexDataTypeTest extends Unit
* Set the dataType.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down
1 change: 1 addition & 0 deletions tests/unit/DataTypes/EmailSettingsDataTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class EmailSettingsDataTypeTest extends Unit
* Set the dataType.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down
1 change: 1 addition & 0 deletions tests/unit/DataTypes/FieldDataTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class FieldDataTypeTest extends Unit
* Set the dataType.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down
1 change: 1 addition & 0 deletions tests/unit/DataTypes/GlobalSetDataTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class GlobalSetDataTypeTest extends Unit
* Set the dataType.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down
1 change: 1 addition & 0 deletions tests/unit/DataTypes/PluginDataTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class PluginDataTypeTest extends Unit
* Set the dataType.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down
1 change: 1 addition & 0 deletions tests/unit/DataTypes/SectionDataTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class SectionDataTypeTest extends Unit
* Set the dataType.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down
1 change: 1 addition & 0 deletions tests/unit/DataTypes/SiteDataTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class SiteDataTypeTest extends Unit
* Set the dataType.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down
1 change: 1 addition & 0 deletions tests/unit/DataTypes/TagGroupDataTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class TagGroupDataTypeTest extends Unit
* Set the dataType.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down
1 change: 1 addition & 0 deletions tests/unit/DataTypes/UserGroupDataTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class UserGroupDataTypeTest extends Unit
* Set the dataType.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down
1 change: 1 addition & 0 deletions tests/unit/DataTypes/UserSettingsDataTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class UserSettingsDataTypeTest extends Unit
* Set the dataType.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down
1 change: 1 addition & 0 deletions tests/unit/DataTypes/VolumeDataTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class VolumeDataTypeTest extends Unit
* Set the dataType.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down
1 change: 1 addition & 0 deletions tests/unit/Mappers/ElementIndexMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ElementIndexMapperTest extends Unit
* Set the mapper.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down
1 change: 1 addition & 0 deletions tests/unit/Mappers/EmailSettingsMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class EmailSettingsMapperTest extends Unit
* Set the mapper.
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
protected function _before()
{
Expand Down

0 comments on commit 9d06950

Please sign in to comment.