Test Setup Failed
Push — master ( 97674e...cd6248 )
by Kevin
01:39
created
test.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@  discard block
 block discarded – undo
19 19
 /* Don't hesitate to use the Faker package to generate random data,
20 20
    there is plenty of data types available (IBAN, address, country code, ...).
21 21
 */
22
-$dataFaker = \Faker\Factory::create();//you could pass the locale to generate localized data !
22
+$dataFaker = \Faker\Factory::create(); //you could pass the locale to generate localized data !
23 23
 
24 24
 // address.postal_code column is a varchar, so default generated data will be text. Here we want a postal code :
25 25
 $generatorFinderBuilder->addGenerator(
26
-    new \DBFaker\Generators\Conditions\CallBackCondition(function(\Doctrine\DBAL\Schema\Table $table,  \Doctrine\DBAL\Schema\Column $column){
26
+    new \DBFaker\Generators\Conditions\CallBackCondition(function(\Doctrine\DBAL\Schema\Table $table, \Doctrine\DBAL\Schema\Column $column) {
27 27
         return $table->getName() == "address" && $column->getName() == "postal_code";
28 28
     }),
29 29
     function() use ($dataFaker){
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
 // all columns that end with "_email" or are named exactly "email" should be emails
35 35
 $generatorFinderBuilder->addGenerator(
36
-    new \DBFaker\Generators\Conditions\CallBackCondition(function(\Doctrine\DBAL\Schema\Table $table,  \Doctrine\DBAL\Schema\Column $column){
36
+    new \DBFaker\Generators\Conditions\CallBackCondition(function(\Doctrine\DBAL\Schema\Table $table, \Doctrine\DBAL\Schema\Column $column) {
37 37
         return preg_match("/([(.*_)|_|]|^)email$/", $column->getName()) === 1;
38 38
     }),
39 39
     function() use ($dataFaker){
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     "community_spending" => 100,
50 50
     "cron_flag" => 10,
51 51
     "project" => 50,
52
-    "project_note" => 200 ,
52
+    "project_note" => 200,
53 53
     "project_steps" => 10,
54 54
     "project_tasks" => 35,
55 55
     "request_hollidays" => 20,
Please login to merge, or discard this patch.
tests/DBFakerTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
             ->column("population")->bigInt()
61 61
             ->column("birthrate")->float()
62 62
             ->column("president_id")->references("persons")
63
-            ->column("population_density")->decimal(10,2)
63
+            ->column("population_density")->decimal(10, 2)
64 64
             ->column("summary")->text();
65 65
 
66 66
         $users->column("country_id")->references("countries");
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
         /* Don't hesitate to use the Faker package to generate random data,
104 104
            there is plenty of data types available (IBAN, address, country code, ...).
105 105
         */
106
-        $dataFaker = \Faker\Factory::create();//you could pass the locale to generate localized data !
106
+        $dataFaker = \Faker\Factory::create(); //you could pass the locale to generate localized data !
107 107
 
108 108
         // address.postal_code column is a varchar, so default generated data will be text. Here we want a postal code :
109 109
         $generatorFinderBuilder->addGenerator(
110
-            new \DBFaker\Generators\Conditions\CallBackCondition(function(\Doctrine\DBAL\Schema\Table $table,  \Doctrine\DBAL\Schema\Column $column){
110
+            new \DBFaker\Generators\Conditions\CallBackCondition(function(\Doctrine\DBAL\Schema\Table $table, \Doctrine\DBAL\Schema\Column $column) {
111 111
                 return $table->getName() == "address" && $column->getName() == "postal_code";
112 112
             }),
113 113
             new SimpleGenerator(
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 
120 120
         // all columns that end with "_email" or are named exactly "email" should be emails
121 121
         $generatorFinderBuilder->addGenerator(
122
-            new CallBackCondition(function(\Doctrine\DBAL\Schema\Table $table,  \Doctrine\DBAL\Schema\Column $column){
122
+            new CallBackCondition(function(\Doctrine\DBAL\Schema\Table $table, \Doctrine\DBAL\Schema\Column $column) {
123 123
                 return preg_match("/([(.*_)|_|]|^)email$/", $column->getName()) === 1;
124 124
             }),
125 125
             new SimpleGenerator(
Please login to merge, or discard this patch.
tests/Generators/Conditions/CheckTypeConditionTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 
9 9
 class CheckTypeConditionTest extends TestCase
10 10
 {
11
-    public function testCanApply(){
11
+    public function testCanApply() {
12 12
         $table = new Table("foo");
13 13
         $column = new Column("bar", Type::getType(Type::DECIMAL));
14 14
 
Please login to merge, or discard this patch.
src/Helpers/NumericColumnLimitHelper.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
      */
35 35
     public function __construct(Column $column)
36 36
     {
37
-        if (array_search($column->getType()->getName(), self::$handledNumberTypes) === false){
37
+        if (array_search($column->getType()->getName(), self::$handledNumberTypes) === false) {
38 38
             throw new UnsupportedDataTypeException("Unsupported column type : " .
39 39
                 $column->getType()->getName() . "only " .
40
-                implode("', '", self::$handledNumberTypes) ." types are supported."
40
+                implode("', '", self::$handledNumberTypes) . " types are supported."
41 41
             );
42 42
         }
43 43
         $this->column = $column;
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     public function getMinNumericValue()
51 51
     {
52 52
         $precisionValue = $this->getAbsValueByLengthPrecision($this->column);
53
-        switch ($this->column->getType()->getName()){
53
+        switch ($this->column->getType()->getName()) {
54 54
             case Type::BIGINT:
55 55
                 return $this->column->getUnsigned() ? 0 : bcpow(2, 63);
56 56
                 break;
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     public function getMaxNumericValue()
77 77
     {
78 78
         $precisionValue = $this->getAbsValueByLengthPrecision($this->column);
79
-        switch ($this->column->getType()->getName()){
79
+        switch ($this->column->getType()->getName()) {
80 80
             case Type::BIGINT:
81 81
                 return $this->column->getUnsigned() ? bcpow(2, 64) : bcpow(2, 63) - 1;
82 82
             case Type::INTEGER:
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      */
97 97
     private function getAbsValueByLengthPrecision(Column $column)
98 98
     {
99
-        switch ($column->getType()->getName()){
99
+        switch ($column->getType()->getName()) {
100 100
             case Type::DECIMAL:
101 101
                 $str = str_repeat(9, $column->getScale());
102 102
                 return (double) substr_replace($str, ".", $column->getScale() - $column->getPrecision(), 0);
Please login to merge, or discard this patch.
src/DBFaker.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public function fakeDB() : void
94 94
     {
95
-        set_time_limit(0);//Import may take a looooong time
95
+        set_time_limit(0); //Import may take a looooong time
96 96
         $this->generateFakeData();
97 97
         $this->dropForeignKeys();
98 98
         $this->insertFakeData();
@@ -125,17 +125,17 @@  discard block
 block discarded – undo
125 125
             foreach ($table->getColumns() as $column) {
126 126
                 //Check column isn't a PK : PK will be set automatically (NO UUID support)
127 127
                 if (array_search($column->getName(), $table->getPrimaryKeyColumns()) !== false) {
128
-                    if ($column->getAutoincrement()){
128
+                    if ($column->getAutoincrement()) {
129 129
                         $value = null;
130
-                    }else{
130
+                    }else {
131 131
                         return $this->getUniqueValue($table, $column);
132 132
                     }
133 133
                 }
134 134
                 //Other data will be Faked depending of column's type and attributes
135 135
                 else {
136
-                    if (!$column->getNotnull() && $this->nullProbabilityOccured()){
136
+                    if (!$column->getNotnull() && $this->nullProbabilityOccured()) {
137 137
                         $value = null;
138
-                    }else{
138
+                    }else {
139 139
                         $value = $this->generatorFinder->findGenerator($table, $column)($column);
140 140
                     }
141 141
                 }
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
     {
155 155
         $this->foreignKeyStore = [];
156 156
         $tables = $this->schemaManager->listTables();
157
-        foreach ($tables as $table){
158
-            foreach ($table->getForeignKeys() as $fk){
157
+        foreach ($tables as $table) {
158
+            foreach ($table->getForeignKeys() as $fk) {
159 159
                 $this->foreignKeyStore[$table->getName()][] = $fk;
160 160
                 $this->schemaManager->dropForeignKey($fk, $table);
161 161
             }
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
      */
168 168
     private function restoreForeignKeys() : void
169 169
     {
170
-        foreach ($this->foreignKeyStore as $tableName => $fks){
171
-            foreach ($fks as $fk){
170
+        foreach ($this->foreignKeyStore as $tableName => $fks) {
171
+            foreach ($fks as $fk) {
172 172
                 $this->schemaManager->createForeignKey($fk, $tableName);
173 173
             }
174 174
         }
@@ -183,14 +183,14 @@  discard block
 block discarded – undo
183 183
     {
184 184
         $plateform = $this->connection->getDatabasePlatform();
185 185
         //1 - First insert data with no FKs, and null PKs. This will generate primary keys
186
-        foreach ($this->data as $tableName => $rows){
186
+        foreach ($this->data as $tableName => $rows) {
187 187
             $table = $this->schemaManager->listTableDetails($tableName);
188 188
 
189 189
             //initiate column types for insert
190 190
             $types = [];
191 191
             $first = reset($rows);
192
-            if ($first){
193
-                foreach ($first as $columnName => $value){
192
+            if ($first) {
193
+                foreach ($first as $columnName => $value) {
194 194
                     /** @var $column Column */
195 195
                     $column = $table->getColumn($columnName);
196 196
                     $types[] = $column->getType()->getBindingType();
@@ -198,9 +198,9 @@  discard block
 block discarded – undo
198 198
             }
199 199
 
200 200
             //insert faked data
201
-            foreach ($rows as $row){
201
+            foreach ($rows as $row) {
202 202
                 $dbRow = [];
203
-                foreach ($row as $columnName => $value){
203
+                foreach ($row as $columnName => $value) {
204 204
                     $column = $table->getColumn($columnName);
205 205
                     $newVal = $column->getType()->convertToDatabaseValue($value, $plateform);
206 206
                     $dbRow[$columnName] = $newVal;
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
         }
214 214
 
215 215
         //2 - loop again on table to set FKs now that all PK have been loaded
216
-        foreach ($this->foreignKeyStore as $tableName => $fks){
217
-            if (array_search($tableName, array_keys($this->fakeTableRowNumbers)) === false){
216
+        foreach ($this->foreignKeyStore as $tableName => $fks) {
217
+            if (array_search($tableName, array_keys($this->fakeTableRowNumbers)) === false) {
218 218
                 //only update tables where data has been inserted
219 219
                 continue;
220 220
             }
@@ -230,11 +230,11 @@  discard block
 block discarded – undo
230 230
              * foreign tables' PKRegistries will provide final values for local FKs columns
231 231
              */
232 232
             $fkInfo = [];
233
-            foreach ($fks as $fk){
233
+            foreach ($fks as $fk) {
234 234
                 $localColums = $fk->getLocalColumns();
235 235
                 $foreignColumns = $fk->getForeignColumns();
236 236
                 $foreignTable = $this->schemaManager->listTableDetails($fk->getForeignTableName());
237
-                foreach ($localColums as $index => $localColumn){
237
+                foreach ($localColums as $index => $localColumn) {
238 238
                     $foreignColumn = $foreignColumns[$index];
239 239
                     $fkInfo[$localColumn] = [
240 240
                         "table" => $foreignTable,
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
 
246 246
             //Get all the PKs in the table (ie all the lines to update), and update the FKs with random PK values
247 247
             $pkValues = $this->getPkRegistry($table)->loadValuesFromTable()->getAllValues();
248
-            foreach ($pkValues as $pkValue){
248
+            foreach ($pkValues as $pkValue) {
249 249
                 $newValues = [];
250
-                foreach ($fkInfo as $localColumn => $foreignData){
250
+                foreach ($fkInfo as $localColumn => $foreignData) {
251 251
                     $foreignTable = $foreignData["table"];
252 252
                     $foreignColumn = $foreignData["column"];
253 253
                     $fkPkRegistry = $this->getPkRegistry($foreignTable);
Please login to merge, or discard this patch.
src/Generators/NumericGenerator.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
         $inspector = new NumericColumnLimitHelper($column);
26 26
         $min = $inspector->getMinNumericValue();
27 27
         $max = $inspector->getMaxNumericValue();
28
-        switch ($column->getType()->getName()){
28
+        switch ($column->getType()->getName()) {
29 29
             case Type::BIGINT:
30 30
                 return $this->bigRandomNumber($min, $max);
31 31
             case Type::INTEGER:
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
             case Type::FLOAT:
36 36
                 return $this->faker->randomFloat(10, $min, $max);
37 37
             default:
38
-                throw new UnsupportedDataTypeException("Cannot generate numeric value for Type : '".$column->getType()->getName()."'");
38
+                throw new UnsupportedDataTypeException("Cannot generate numeric value for Type : '" . $column->getType()->getName() . "'");
39 39
         }
40 40
     }
41 41
 
42 42
     private function bigRandomNumber($min, $max) {
43
-        $difference   = bcadd(bcsub($max,$min),1);
43
+        $difference   = bcadd(bcsub($max, $min), 1);
44 44
         $rand_percent = bcdiv(mt_rand(), mt_getrandmax(), 8); // 0 - 1.0
45 45
         return bcadd($min, bcmul($difference, $rand_percent, 8), 0);
46 46
     }
Please login to merge, or discard this patch.
src/Generators/BlobGenerator.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,11 +20,11 @@
 block discarded – undo
20 20
     public function __invoke(Column $column)
21 21
     {
22 22
         $files = glob($this->globExpression, GLOB_MARK);
23
-        $files = array_filter($files, function ($fileName){
23
+        $files = array_filter($files, function($fileName) {
24 24
             return strrpos($fileName, DIRECTORY_SEPARATOR) !== strlen($fileName) - 1;
25 25
         });
26
-        if (count($files) == 0){
27
-            throw new NoTestFilesFoundException("No files found for glob expression '".$this->globExpression."'");
26
+        if (count($files) == 0) {
27
+            throw new NoTestFilesFoundException("No files found for glob expression '" . $this->globExpression . "'");
28 28
         }
29 29
         $files = array_values($files);
30 30
         $chosenFile = $files[random_int(0, count($files) - 1)];
Please login to merge, or discard this patch.
src/Generators/GeneratorFinderBuilder.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     /**
30 30
      * @return GeneratorFinderBuilder
31 31
      */
32
-    public static function buildDefaultFinderBuilder(){
32
+    public static function buildDefaultFinderBuilder() {
33 33
         $faker = Factory::create();
34 34
         $builder = new GeneratorFinderBuilder([]);
35 35
 
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
                 new CheckTypeCondition(Type::GUID),
153 153
                 new SimpleGenerator(function() {
154 154
                     $chars = "0123456789abcdef";
155
-                    $groups = [8 ,4, 4, 4, 12];
155
+                    $groups = [8, 4, 4, 4, 12];
156 156
                     $guid = [];
157
-                    foreach ($groups as $length){
157
+                    foreach ($groups as $length) {
158 158
                         $sub = "";
159
-                        for ($i = 0; $i < $length; $i++){
159
+                        for ($i = 0; $i < $length; $i++) {
160 160
                             $sub .= $chars[random_int(0, count($chars) - 1)];
161 161
                         }
162 162
                         $guid[] = $sub;
Please login to merge, or discard this patch.
src/Generators/Conditions/CheckTypeCondition.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
      */
22 22
     public function __construct(Type $type)
23 23
     {
24
-        if (!Type::hasType($type)){
24
+        if (!Type::hasType($type)) {
25 25
             throw new UnsupportedDataTypeException("Type '$$type' is not supported, please add it to DBAL types list (see Type::addType())");
26 26
         }
27 27
         $this->type = Type::getType($type);
Please login to merge, or discard this patch.