Skip to content

Commit c78b9f3

Browse files
committed
MQE-148: Add Code Sniffer static test to Acceptance Test Framework & Tests projects and run it in Jenkins
1 parent 44962f8 commit c78b9f3

23 files changed

+356
-108
lines changed

src/Magento/AcceptanceTestFramework/DataGenerator/Api/ApiExecutor.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
36
namespace Magento\AcceptanceTestFramework\DataGenerator\Api;
47

58
use Magento\AcceptanceTestFramework\DataGenerator\Handlers\DataObjectHandler;
@@ -12,8 +15,9 @@ class ApiExecutor
1215
{
1316
/**
1417
* Describes the operation for the executor ('create','update','delete')
15-
* @var string $operation
16-
**/
18+
*
19+
* @var string
20+
*/
1721
private $operation;
1822

1923
/**
@@ -32,7 +36,6 @@ class ApiExecutor
3236

3337
/**
3438
* ApiSubObject constructor.
35-
* @constructor
3639
* @param string $operation
3740
* @param EntityDataObject $entityObject
3841
*/
@@ -49,6 +52,7 @@ public function __construct($operation, $entityObject)
4952

5053
/**
5154
* Executes an api request based on parameters given by constructor.
55+
*
5256
* @return string | null
5357
*/
5458
public function executeRequest()
@@ -153,6 +157,7 @@ private function getJsonDataArray($entityObject, $jsonDefMetadata = null)
153157

154158
/**
155159
* This function retrieves an array representative of json body for a request and returns it encoded as a string.
160+
*
156161
* @return string
157162
*/
158163
public function getEncodedJsonString()
@@ -162,12 +167,14 @@ public function getEncodedJsonString()
162167
return json_encode([$this->entityObject->getType() => $jsonArray], JSON_PRETTY_PRINT);
163168
}
164169

170+
// @codingStandardsIgnoreStart
165171
/**
166172
* This function takes a string value and its corresponding type and returns the string cast
167173
* into its the type passed.
174+
*
168175
* @param string $type
169176
* @param string $value
170-
* @return bool|float|int|string
177+
* @return mixed
171178
*/
172179
private function castValue($type, $value)
173180
{
@@ -189,4 +196,5 @@ private function castValue($type, $value)
189196

190197
return $newVal;
191198
}
199+
// @codingStandardsIgnoreEnd
192200
}

src/Magento/AcceptanceTestFramework/DataGenerator/Api/EntityApiHandler.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
26

37
namespace Magento\AcceptanceTestFramework\DataGenerator\Api;
48

@@ -8,19 +12,20 @@ class EntityApiHandler
812
{
913
/**
1014
* Entity object data to use for create, delete, or update.
15+
*
1116
* @var EntityDataObject $entityObject
1217
*/
1318
private $entityObject;
1419

1520
/**
1621
* Resulting created object from create or update.
22+
*
1723
* @var EntityDataObject $createdObject
1824
*/
1925
private $createdObject;
2026

2127
/**
2228
* ApiPersistenceHandler constructor.
23-
* @constructor
2429
* @param EntityDataObject $entityObject
2530
*/
2631
public function __construct($entityObject)
@@ -30,6 +35,7 @@ public function __construct($entityObject)
3035

3136
/**
3237
* Function which executes a create request based on specific operation metadata
38+
*
3339
* @return string | false
3440
*/
3541
public function createEntity()
@@ -49,6 +55,7 @@ public function createEntity()
4955

5056
/**
5157
* Function which executes a delete request based on specific operation metadata
58+
*
5259
* @return string | false
5360
*/
5461
public function deleteEntity()

src/Magento/AcceptanceTestFramework/DataGenerator/Handlers/DataObjectHandler.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Magento\AcceptanceTestFramework\ObjectManager\ObjectHandlerInterface;
88
use Magento\AcceptanceTestFramework\ObjectManagerFactory;
99

10+
// @codingStandardsIgnoreFile
1011
class DataObjectHandler implements ObjectHandlerInterface
1112
{
1213
/**

src/Magento/AcceptanceTestFramework/DataGenerator/Handlers/JsonDefinitionObjectHandler.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010

1111
class JsonDefinitionObjectHandler implements ObjectHandlerInterface
1212
{
13-
/**
14-
* Singleton Instance of class
15-
* @var JsonDefinitionObjectHandler $JSON_DEFINITION_ARRAY_PROCESSOR
16-
*/
17-
private static $JSON_DEFINITION_OBJECT_HANDLER;
18-
1913
const ENTITY_OPERATION_ROOT_TAG = 'operation';
2014
const ENTITY_OPERATION_TYPE = 'type';
2115
const ENTITY_OPERATION_DATA_TYPE = 'dataType';
@@ -36,14 +30,23 @@ class JsonDefinitionObjectHandler implements ObjectHandlerInterface
3630
const ENTITY_OPERATION_ARRAY_KEY = 'key';
3731
const ENTITY_OPERATION_ARRAY_VALUE = 'value';
3832

33+
/**
34+
* Singleton Instance of class
35+
*
36+
* @var JsonDefinitionObjectHandler
37+
*/
38+
private static $JSON_DEFINITION_OBJECT_HANDLER;
39+
3940
/**
4041
* Array containing all Json Definition Objects
41-
* @var array $jsonDefinitions
42+
*
43+
* @var array
4244
*/
4345
private $jsonDefinitions = [];
4446

4547
/**
4648
* Singleton method to return JsonDefinitionProcessor.
49+
*
4750
* @return JsonDefinitionObjectHandler
4851
*/
4952
public static function getInstance()
@@ -58,7 +61,8 @@ public static function getInstance()
5861

5962
/**
6063
* Returns a JsonDefinition object based on name
61-
* @param string $jsonDefitionName
64+
*
65+
* @param string $jsonDefinitionName
6266
* @return JsonDefinition
6367
*/
6468
public function getObject($jsonDefinitionName)
@@ -68,6 +72,7 @@ public function getObject($jsonDefinitionName)
6872

6973
/**
7074
* Returns all Json Definition objects
75+
*
7176
* @return array
7277
*/
7378
public function getAllObjects()
@@ -77,7 +82,6 @@ public function getAllObjects()
7782

7883
/**
7984
* JsonDefintionArrayProcessor constructor.
80-
* @constructor
8185
*/
8286
private function __construct()
8387
{
@@ -87,6 +91,7 @@ private function __construct()
8791
/**
8892
* This method takes an operation such as create and a data type such as 'customer' and returns the corresponding
8993
* json definition defined in metadata.xml
94+
*
9095
* @param string $operation
9196
* @param string $dataType
9297
* @return JsonDefinition
@@ -98,6 +103,7 @@ public function getJsonDefinition($operation, $dataType)
98103

99104
/**
100105
* This method reads all jsonDefinitions from metadata xml into memory.
106+
* @return void
101107
*/
102108
private function initJsonDefinitions()
103109
{

src/Magento/AcceptanceTestFramework/DataGenerator/Objects/EntityDataObject.php

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,41 @@
11
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
26

37
namespace Magento\AcceptanceTestFramework\DataGenerator\Objects;
48

9+
/**
10+
* Class EntityDataObject
11+
*/
512
class EntityDataObject
613
{
714
/**
815
* Name of the entity
9-
* @var string $name
16+
*
17+
* @var string
1018
*/
1119
private $name;
1220

1321
/**
1422
* Type of the entity
15-
* @var string $type
23+
*
24+
* @var string
1625
*/
1726
private $type;
1827

1928
/**
2029
* An array of required entity name to corresponding type
21-
* @var array $linkedEntities
30+
*
31+
* @var array
2232
*/
2333
private $linkedEntities = [];
2434

2535
/**
2636
* An array of Data Name to Data Value
27-
* @var array $data
37+
*
38+
* @var array
2839
*/
2940
private $data = [];
3041

@@ -45,6 +56,7 @@ public function __construct($entityName, $entityType, $data, $linkedEntities)
4556

4657
/**
4758
* Getter for linked entity names
59+
*
4860
* @return array
4961
*/
5062
public function getLinkedEntities()
@@ -54,6 +66,7 @@ public function getLinkedEntities()
5466

5567
/**
5668
* Getter for entity name
69+
*
5770
* @return string
5871
*/
5972
public function getName()
@@ -63,6 +76,7 @@ public function getName()
6376

6477
/**
6578
* Getter for entity type
79+
*
6680
* @return string
6781
*/
6882
public function getType()
@@ -74,7 +88,7 @@ public function getType()
7488
* This function retrieves data from an entity defined in xml.
7589
*
7690
* @param string $dataName
77-
* @return string
91+
* @return string|null
7892
*/
7993
public function getDataByName($dataName)
8094
{

0 commit comments

Comments
 (0)