Completed
Push — feature/get-db-from-arg ( ebfde4...c6d810 )
by Lucas
08:11 queued 04:42
created
src/Command/CoreImportCommand.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@
 block discarded – undo
97 97
     /**
98 98
      * import a single file into a collection
99 99
      *
100
-     * @param SplFileInfo     $file   file
100
+     * @param \SplFileInfo     $file   file
101 101
      * @param InputInterface  $input  User input on console
102 102
      * @param OutputInterface $output Output of the command
103 103
      *
Please login to merge, or discard this patch.
test/Command/CoreImportCommandTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         $clientMock = $this->getMockBuilder('\MongoClient')->disableOriginalConstructor()->getMock();
52 52
 
53 53
         $collection = $this->getMockBuilder('\MongoCollection')->disableOriginalConstructor()->getMock();
54
-        $collection->method('save')->will($this->returnCallback(array($this,'saveCollectionCallback')));
54
+        $collection->method('save')->will($this->returnCallback(array($this, 'saveCollectionCallback')));
55 55
         $clientMock->method('selectCollection')->willReturn($collection);
56 56
 
57 57
         $sut = new CoreImportCommand(
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
         // fail in output?
114 114
         $this->assertContains(
115
-            'Could not deserialize file <' . $this->sourceDir . '/Dudess/Invalid.json>',
115
+            'Could not deserialize file <'.$this->sourceDir.'/Dudess/Invalid.json>',
116 116
             $this->cmdTester->getDisplay()
117 117
         );
118 118
     }
Please login to merge, or discard this patch.
src/Command/ImportCommandAbstract.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
          * @param SplFileInfo $file
53 53
          * @return bool
54 54
          */
55
-        $filter = function (SplFileInfo $file) {
56
-            if (!in_array($file->getExtension(), ['yml','json']) || $file->isDir()) {
55
+        $filter = function(SplFileInfo $file) {
56
+            if (!in_array($file->getExtension(), ['yml', 'json']) || $file->isDir()) {
57 57
                 return false;
58 58
             }
59 59
             return true;
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         try {
65 65
             $this->doImport($finder, $input, $output);
66 66
         } catch (MissingTargetException $e) {
67
-            $output->writeln('<error>' . $e->getMessage() . '</error>');
67
+            $output->writeln('<error>'.$e->getMessage().'</error>');
68 68
         }
69 69
     }
70 70
 
Please login to merge, or discard this patch.
test/Command/ImportCommandTest.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -51,13 +51,13 @@  discard block
 block discarded – undo
51 51
         $responseMock
52 52
             ->method('getHeader')
53 53
             ->with('Link')
54
-            ->willReturn(['<' . $host . $path . '>; rel="self"']);
54
+            ->willReturn(['<'.$host.$path.'>; rel="self"']);
55 55
 
56 56
         $promiseMock
57 57
             ->method('then')
58 58
             ->will(
59 59
                 $this->returnCallback(
60
-                    function ($ok) use ($responseMock) {
60
+                    function($ok) use ($responseMock) {
61 61
                         $ok($responseMock);
62 62
                     }
63 63
                 )
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 
75 75
         $cmdTester = $this->getTester($sut, $file);
76 76
 
77
-        $this->assertContains('Loading data from ' . $file, $cmdTester->getDisplay());
78
-        $this->assertContains('Wrote <' . $host . $path . '>; rel="self"', $cmdTester->getDisplay());
77
+        $this->assertContains('Loading data from '.$file, $cmdTester->getDisplay());
78
+        $this->assertContains('Wrote <'.$host.$path.'>; rel="self"', $cmdTester->getDisplay());
79 79
     }
80 80
 
81 81
     /**
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         return [
87 87
             'basic valid file' => [
88 88
                 'http://localhost',
89
-                __DIR__ . '/fixtures/set-01/test-2.json',
89
+                __DIR__.'/fixtures/set-01/test-2.json',
90 90
                 '/core/app/test',
91 91
             ],
92 92
         ];
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         return [
101 101
             'basic valid image file' => [
102 102
                 'http://localhost',
103
-                __DIR__ . '/fixtures/file',
103
+                __DIR__.'/fixtures/file',
104 104
                 '/core/app/test',
105 105
             ],
106 106
         ];
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         $requestMock = $this->getMock('Psr\Http\Message\RequestInterface');
135 135
         $requestMock
136 136
             ->method('getUri')
137
-            ->willReturn($host . '/core/app/test');
137
+            ->willReturn($host.'/core/app/test');
138 138
 
139 139
         $exceptionMock = $this->getMockBuilder('GuzzleHttp\Exception\RequestException')
140 140
             ->setConstructorArgs(['Client error: 400', $requestMock, $responseMock])
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
             ->method('then')
153 153
             ->will(
154 154
                 $this->returnCallback(
155
-                    function ($ok, $nok) use ($exceptionMock) {
155
+                    function($ok, $nok) use ($exceptionMock) {
156 156
                         return $nok($exceptionMock);
157 157
                     }
158 158
                 )
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 
170 170
         $cmdTester = $this->getTester($sut, $file);
171 171
 
172
-        $this->assertContains('Loading data from ' . $file, $cmdTester->getDisplay());
172
+        $this->assertContains('Loading data from '.$file, $cmdTester->getDisplay());
173 173
         foreach ($errors as $error) {
174 174
             $this->assertContains(
175 175
                 $error,
@@ -186,18 +186,18 @@  discard block
 block discarded – undo
186 186
         return [
187 187
             'invalid file (server side)' => [
188 188
                 'http://localhost',
189
-                __DIR__ . '/fixtures/set-01/test.json',
189
+                __DIR__.'/fixtures/set-01/test.json',
190 190
                 [
191
-                    'Failed to write <http://localhost/core/app/test> from \'' .
192
-                    __DIR__ . '/fixtures/set-01/test.json\' with message \'Client error: 400\'',
191
+                    'Failed to write <http://localhost/core/app/test> from \''.
192
+                    __DIR__.'/fixtures/set-01/test.json\' with message \'Client error: 400\'',
193 193
                     '"message": "invalid"',
194 194
                 ],
195 195
             ],
196 196
             'missing target in file (user error)' => [
197 197
                 'http://localhost',
198
-                __DIR__ . '/fixtures/set-01/test-3.json',
198
+                __DIR__.'/fixtures/set-01/test-3.json',
199 199
                 [
200
-                    'Missing target in \'' . __DIR__ . '/fixtures/set-01/test-3.json\'',
200
+                    'Missing target in \''.__DIR__.'/fixtures/set-01/test-3.json\'',
201 201
                 ],
202 202
             ]
203 203
         ];
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
             ->method('then')
235 235
             ->will(
236 236
                 $this->returnCallback(
237
-                    function ($ok) use ($responseMock) {
237
+                    function($ok) use ($responseMock) {
238 238
                         $ok($responseMock);
239 239
                     }
240 240
                 )
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 
252 252
         $cmdTester = $this->getTester(
253 253
             $sut,
254
-            __DIR__ . '/fixtures/set-01/test-4.json',
254
+            __DIR__.'/fixtures/set-01/test-4.json',
255 255
             [
256 256
                 'host' => 'http://example.com',
257 257
                 '--rewrite-host' => 'http://localhost'
Please login to merge, or discard this patch.
src/Command/ImportCommand.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
             $output->writeln("<info>Loading data from ${file}</info>");
202 202
 
203 203
             if (!array_key_exists('target', $doc->getData())) {
204
-                throw new MissingTargetException('Missing target in \'' . $file . '\'');
204
+                throw new MissingTargetException('Missing target in \''.$file.'\'');
205 205
             }
206 206
 
207 207
             $targetUrl = sprintf('%s%s', $host, $doc->getData()['target']);
@@ -247,16 +247,16 @@  discard block
 block discarded – undo
247 247
         $content = str_replace($rewriteHost, $rewriteTo, $doc->getContent());
248 248
         $uploadFile = $this->validateUploadFile($doc, $file);
249 249
 
250
-        $successFunc = function (ResponseInterface $response) use ($output) {
250
+        $successFunc = function(ResponseInterface $response) use ($output) {
251 251
             $output->writeln(
252
-                '<comment>Wrote ' . $response->getHeader('Link')[0] . '</comment>'
252
+                '<comment>Wrote '.$response->getHeader('Link')[0].'</comment>'
253 253
             );
254 254
         };
255 255
 
256
-        $errFunc = function (RequestException $e) use ($output, $file) {
256
+        $errFunc = function(RequestException $e) use ($output, $file) {
257 257
             $this->errors[$file] = $e->getMessage();
258 258
             $output->writeln(
259
-                '<error>' . str_pad(
259
+                '<error>'.str_pad(
260 260
                     sprintf(
261 261
                         'Failed to write <%s> from \'%s\' with message \'%s\'',
262 262
                         $e->getRequest()->getUri(),
@@ -265,17 +265,17 @@  discard block
 block discarded – undo
265 265
                     ),
266 266
                     140,
267 267
                     ' '
268
-                ) . '</error>'
268
+                ).'</error>'
269 269
             );
270 270
             if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
271 271
                 $this->dumper->dump(
272 272
                     $this->cloner->cloneVar(
273 273
                         $this->parser->parse($e->getResponse()->getBody(), false, false, true)
274 274
                     ),
275
-                    function ($line, $depth) use ($output) {
275
+                    function($line, $depth) use ($output) {
276 276
                         if ($depth > 0) {
277 277
                             $output->writeln(
278
-                                '<error>' . str_pad(str_repeat('  ', $depth) . $line, 140, ' ') . '</error>'
278
+                                '<error>'.str_pad(str_repeat('  ', $depth).$line, 140, ' ').'</error>'
279 279
                             );
280 280
                         }
281 281
                     }
@@ -296,11 +296,11 @@  discard block
 block discarded – undo
296 296
         // If there is a file to be uploaded, and it exists in remote, we delete it first.
297 297
         $fileRepeatFunc = false;
298 298
         if ($uploadFile) {
299
-            $fileRepeatFunc = function () use ($targetUrl, $successFunc, $errFunc, $output, $file, $data) {
299
+            $fileRepeatFunc = function() use ($targetUrl, $successFunc, $errFunc, $output, $file, $data) {
300 300
                 unset($this->errors[$file]);
301 301
                 $output->writeln('<info>File deleting: '.$targetUrl.'</info>');
302 302
                 $deleteRequest = $this->client->requestAsync('DELETE', $targetUrl);
303
-                $insert = function () use ($targetUrl, $successFunc, $errFunc, $output, $data) {
303
+                $insert = function() use ($targetUrl, $successFunc, $errFunc, $output, $data) {
304 304
                     $output->writeln('<info>File inserting: '.$targetUrl.'</info>');
305 305
                     $promiseInsert = $this->client->requestAsync('PUT', $targetUrl, $data);
306 306
                     $promiseInsert->then($successFunc, $errFunc);
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
         }
371 371
 
372 372
         // Find file
373
-        $fileName = dirname($originFile) . DIRECTORY_SEPARATOR . $documentData['file'];
373
+        $fileName = dirname($originFile).DIRECTORY_SEPARATOR.$documentData['file'];
374 374
         $fileName = str_replace('//', '/', $fileName);
375 375
         if (!file_exists($fileName)) {
376 376
             return false;
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
      * @param InputInterface  $input  User input on console
143 143
      * @param OutputInterface $output Output of the command
144 144
      *
145
-     * @return void
145
+     * @return integer
146 146
      */
147 147
     protected function doImport(Finder $finder, InputInterface $input, OutputInterface $output)
148 148
     {
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
      * @param string          $rewriteTo   string to replace value from $rewriteHost with during loading
233 233
      * @param boolean         $sync        send requests syncronously
234 234
      *
235
-     * @return Promise\Promise|null
235
+     * @return Promise\PromiseInterface
236 236
      */
237 237
     protected function importResource(
238 238
         $targetUrl,
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
      *
360 360
      * @param Document $doc        Data source for import data
361 361
      * @param string   $originFile Original full filename used toimport
362
-     * @return bool|mixed
362
+     * @return false|string
363 363
      */
364 364
     private function validateUploadFile(Document $doc, $originFile)
365 365
     {
Please login to merge, or discard this patch.