Passed
Push — master ( 5bb5b8...56640d )
by Francesco
02:55
created
Tests/KeyManagerTest.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
     public function testGenerateCreatesKey()
38 38
     {
39 39
         $this->keyGenerator->expects($this->once())
40
-                           ->method('generate')
41
-                           ->with(null)
42
-                           ->will($this->returnValue($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
43
-                                                          ->getMock()));
40
+                            ->method('generate')
41
+                            ->with(null)
42
+                            ->will($this->returnValue($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
43
+                                                            ->getMock()));
44 44
 
45 45
         $key = $this->keyManager->generate();
46 46
 
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
         $secret = 'ThisIsASecretPassword';
54 54
 
55 55
         $this->keyGenerator->expects($this->once())
56
-                           ->method('generateFromAscii')
57
-                           ->with($key_encoded, $secret)
58
-                           ->will($this->returnValue($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
59
-                                                          ->getMock()));
56
+                            ->method('generateFromAscii')
57
+                            ->with($key_encoded, $secret)
58
+                            ->will($this->returnValue($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
59
+                                                            ->getMock()));
60 60
 
61 61
         $key = $this->keyManager->generateFromAscii($key_encoded, $secret);
62 62
 
@@ -66,17 +66,17 @@  discard block
 block discarded – undo
66 66
     public function testGetKeyReadsNotExistingKey()
67 67
     {
68 68
         $this->keyStorage->expects($this->once())
69
-                         ->method('getKey')
70
-                         ->will($this->returnValue(null));
69
+                            ->method('getKey')
70
+                            ->will($this->returnValue(null));
71 71
 
72 72
         $this->keyGenerator->expects($this->once())
73
-                           ->method('generate')
74
-                           ->with(null)
75
-                           ->will($this->returnValue($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
76
-                                                          ->getMock()));
73
+                            ->method('generate')
74
+                            ->with(null)
75
+                            ->will($this->returnValue($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
76
+                                                            ->getMock()));
77 77
 
78 78
         $this->keyStorage->expects($this->once())
79
-                         ->method('setKey');
79
+                            ->method('setKey');
80 80
 
81 81
         $key = $this->keyManager->getKey();
82 82
 
@@ -86,14 +86,14 @@  discard block
 block discarded – undo
86 86
     public function testGetKeyReadsExistingKey()
87 87
     {
88 88
         $this->keyStorage->expects($this->never())
89
-                         ->method('setKey');
89
+                            ->method('setKey');
90 90
 
91 91
         $this->keyGenerator->expects($this->never())
92
-                           ->method('generate');
92
+                            ->method('generate');
93 93
 
94 94
         $this->keyStorage->expects($this->once())
95
-                         ->method('getKey')
96
-                         ->will($this->returnValue($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
95
+                            ->method('getKey')
96
+                            ->will($this->returnValue($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
97 97
                                                         ->getMock()));
98 98
 
99 99
         $key = $this->keyManager->getKey();
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
     public function testSetKeyStoresKey()
105 105
     {
106 106
         $this->keyStorage->expects($this->once())
107
-                         ->method('setKey')
108
-                         ->with($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
109
-                                     ->getMock());
107
+                            ->method('setKey')
108
+                            ->with($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
109
+                                        ->getMock());
110 110
 
111 111
         $this->keyManager->setKey($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
112
-                                       ->getMock());
112
+                                        ->getMock());
113 113
     }
114 114
 
115 115
     public function testSetSecretStoreSecret()
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
     protected function setUp()
123 123
     {
124 124
         $this->keyStorage = $this->getMockBuilder('Mes\Security\CryptoBundle\KeyStorage\KeyStorageInterface')
125
-                                 ->getMock();
125
+                                    ->getMock();
126 126
 
127 127
         $this->keyGenerator = $this->getMockBuilder('Mes\Security\CryptoBundle\KeyGenerator\KeyGeneratorInterface')
128
-                                   ->getMock();
128
+                                    ->getMock();
129 129
 
130 130
         $this->keyManager = new KeyManager($this->keyStorage, $this->keyGenerator);
131 131
     }
Please login to merge, or discard this patch.
Tests/EncryptionWrapperTest.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     protected function setUp()
38 38
     {
39 39
         $this->encryption = $this->getMockBuilder('Mes\Security\CryptoBundle\EncryptionInterface')
40
-                                 ->getMock();
40
+                                    ->getMock();
41 41
         $this->wrapper = new EncryptionWrapper($this->encryption);
42 42
     }
43 43
 
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
     public function testEncryptWithKeyEncryptsPlaintext()
54 54
     {
55 55
         $this->encryption->expects($this->once())
56
-                         ->method('encryptWithKey')
57
-                         ->with('The quick brown fox jumps over the lazy dog', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock())
58
-                         ->will($this->returnValue('ThisIsACipherText'));
56
+                            ->method('encryptWithKey')
57
+                            ->with('The quick brown fox jumps over the lazy dog', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock())
58
+                            ->will($this->returnValue('ThisIsACipherText'));
59 59
 
60 60
         $ciphertext = $this->wrapper->encryptWithKey('The quick brown fox jumps over the lazy dog', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock());
61 61
 
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
     {
70 70
         try {
71 71
             $this->encryption->expects($this->once())
72
-                             ->method('encryptWithKey')
73
-                             ->with('The quick brown fox jumps over the lazy dog', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock())
74
-                             ->will($this->throwException(new EnvironmentIsBrokenException()));
72
+                                ->method('encryptWithKey')
73
+                                ->with('The quick brown fox jumps over the lazy dog', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock())
74
+                                ->will($this->throwException(new EnvironmentIsBrokenException()));
75 75
         } catch (EnvironmentIsBrokenException $e) {
76 76
             $this->throwException(new CryptoException());
77 77
         }
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
     public function testDecryptWithKeyDecryptsCiphertext()
86 86
     {
87 87
         $this->encryption->expects($this->once())
88
-                         ->method('decryptWithKey')
89
-                         ->with('ThisIsACipherText', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock())
90
-                         ->will($this->returnValue('The quick brown fox jumps over the lazy dog'));
88
+                            ->method('decryptWithKey')
89
+                            ->with('ThisIsACipherText', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock())
90
+                            ->will($this->returnValue('The quick brown fox jumps over the lazy dog'));
91 91
 
92 92
         $decryptedText = $this->wrapper->decryptWithKey('ThisIsACipherText', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock());
93 93
 
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
     {
102 102
         try {
103 103
             $this->encryption->expects($this->once())
104
-                             ->method('decryptWithKey')
105
-                             ->with('ThisIsACipherText', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock())
106
-                             ->will($this->throwException(new BaseCryptoException()));
104
+                                ->method('decryptWithKey')
105
+                                ->with('ThisIsACipherText', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock())
106
+                                ->will($this->throwException(new BaseCryptoException()));
107 107
         } catch (BaseCryptoException $e) {
108 108
             $this->throwException(new CryptoException());
109 109
         }
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
     public function testEncryptWithKeyFileEncryptsFile()
118 118
     {
119 119
         $this->encryption->expects($this->once())
120
-                         ->method('encryptFileWithKey')
121
-                         ->will($this->returnCallback(function ($input, $output) {
122
-                             $fs = new Filesystem();
123
-                             $fs->dumpFile($output, '');
124
-                         }));
120
+                            ->method('encryptFileWithKey')
121
+                            ->will($this->returnCallback(function ($input, $output) {
122
+                                $fs = new Filesystem();
123
+                                $fs->dumpFile($output, '');
124
+                            }));
125 125
 
126 126
         $this->wrapper->encryptFileWithKey(__DIR__.'/file.txt', __DIR__.'/file.crypto', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock());
127 127
 
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
     public function testDecryptWithKeyFileDecryptsEncryptedFile()
137 137
     {
138 138
         $this->encryption->expects($this->once())
139
-                         ->method('decryptFileWithKey')
140
-                         ->will($this->returnCallback(function ($input, $output) {
141
-                             $fs = new Filesystem();
142
-                             $fs->dumpFile($output, 'Plain text');
143
-                         }));
139
+                            ->method('decryptFileWithKey')
140
+                            ->will($this->returnCallback(function ($input, $output) {
141
+                                $fs = new Filesystem();
142
+                                $fs->dumpFile($output, 'Plain text');
143
+                            }));
144 144
 
145 145
         $this->wrapper->decryptFileWithKey(__DIR__.'/file.crypto', __DIR__.'/file.txt', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock());
146 146
 
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
     {
158 158
         try {
159 159
             $this->encryption->expects($this->once())
160
-                             ->method('encryptFileWithKey')
161
-                             ->will($this->throwException(new BaseCryptoException()));
160
+                                ->method('encryptFileWithKey')
161
+                                ->will($this->throwException(new BaseCryptoException()));
162 162
         } catch (BaseCryptoException $e) {
163 163
             $this->throwException(new CryptoException());
164 164
         }
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
     {
174 174
         try {
175 175
             $this->encryption->expects($this->once())
176
-                             ->method('decryptFileWithKey')
177
-                             ->will($this->throwException(new BaseCryptoException()));
176
+                                ->method('decryptFileWithKey')
177
+                                ->will($this->throwException(new BaseCryptoException()));
178 178
         } catch (BaseCryptoException $e) {
179 179
             $this->throwException(new CryptoException());
180 180
         }
@@ -185,9 +185,9 @@  discard block
 block discarded – undo
185 185
     public function testEncryptWithPasswordEncryptsPlaintext()
186 186
     {
187 187
         $this->encryption->expects($this->once())
188
-                         ->method('encryptWithPassword')
189
-                         ->with('The quick brown fox jumps over the lazy dog', 'SuperSecretPa$$word')
190
-                         ->will($this->returnValue('ThisIsACipherText'));
188
+                            ->method('encryptWithPassword')
189
+                            ->with('The quick brown fox jumps over the lazy dog', 'SuperSecretPa$$word')
190
+                            ->will($this->returnValue('ThisIsACipherText'));
191 191
 
192 192
         $ciphertext = $this->wrapper->encryptWithPassword('The quick brown fox jumps over the lazy dog', 'SuperSecretPa$$word');
193 193
 
@@ -201,9 +201,9 @@  discard block
 block discarded – undo
201 201
     {
202 202
         try {
203 203
             $this->encryption->expects($this->once())
204
-                             ->method('encryptWithPassword')
205
-                             ->with('The quick brown fox jumps over the lazy dog', 'SuperSecretPa$$word')
206
-                             ->will($this->throwException(new EnvironmentIsBrokenException()));
204
+                                ->method('encryptWithPassword')
205
+                                ->with('The quick brown fox jumps over the lazy dog', 'SuperSecretPa$$word')
206
+                                ->will($this->throwException(new EnvironmentIsBrokenException()));
207 207
         } catch (EnvironmentIsBrokenException $e) {
208 208
             $this->throwException(new CryptoException());
209 209
         }
@@ -214,9 +214,9 @@  discard block
 block discarded – undo
214 214
     public function testDecryptWithPasswordDecryptsCiphertext()
215 215
     {
216 216
         $this->encryption->expects($this->once())
217
-                         ->method('decryptWithPassword')
218
-                         ->with('ThisIsACipherText', 'SuperSecretPa$$word')
219
-                         ->will($this->returnValue('The quick brown fox jumps over the lazy dog'));
217
+                            ->method('decryptWithPassword')
218
+                            ->with('ThisIsACipherText', 'SuperSecretPa$$word')
219
+                            ->will($this->returnValue('The quick brown fox jumps over the lazy dog'));
220 220
 
221 221
         $decryptedText = $this->wrapper->decryptWithPassword('ThisIsACipherText', 'SuperSecretPa$$word');
222 222
 
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
     {
231 231
         try {
232 232
             $this->encryption->expects($this->once())
233
-                             ->method('decryptWithPassword')
234
-                             ->with('ThisIsACipherText', 'SuperSecretPa$$word')
235
-                             ->will($this->throwException(new WrongKeyOrModifiedCiphertextException()));
233
+                                ->method('decryptWithPassword')
234
+                                ->with('ThisIsACipherText', 'SuperSecretPa$$word')
235
+                                ->will($this->throwException(new WrongKeyOrModifiedCiphertextException()));
236 236
         } catch (BaseCryptoException $e) {
237 237
             $this->throwException(new CryptoException());
238 238
         }
@@ -243,11 +243,11 @@  discard block
 block discarded – undo
243 243
     public function testEncryptFileWithPasswordEncryptsFile()
244 244
     {
245 245
         $this->encryption->expects($this->once())
246
-                         ->method('encryptFileWithPassword')
247
-                         ->will($this->returnCallback(function ($input, $output, $password) {
248
-                             $fs = new Filesystem();
249
-                             $fs->dumpFile($output, '');
250
-                         }));
246
+                            ->method('encryptFileWithPassword')
247
+                            ->will($this->returnCallback(function ($input, $output, $password) {
248
+                                $fs = new Filesystem();
249
+                                $fs->dumpFile($output, '');
250
+                            }));
251 251
 
252 252
         $this->wrapper->encryptFileWithPassword(__DIR__.'/file.txt', __DIR__.'/file.crypto', 'SuperSecretPa$$word');
253 253
 
@@ -263,8 +263,8 @@  discard block
 block discarded – undo
263 263
     {
264 264
         try {
265 265
             $this->encryption->expects($this->once())
266
-                             ->method('encryptFileWithPassword')
267
-                             ->will($this->throwException(new EnvironmentIsBrokenException()));
266
+                                ->method('encryptFileWithPassword')
267
+                                ->will($this->throwException(new EnvironmentIsBrokenException()));
268 268
         } catch (EnvironmentIsBrokenException $e) {
269 269
             $this->throwException(new CryptoException());
270 270
         }
@@ -275,11 +275,11 @@  discard block
 block discarded – undo
275 275
     public function testDecryptFileWithPasswordDecryptsEncryptedFile()
276 276
     {
277 277
         $this->encryption->expects($this->once())
278
-                         ->method('decryptFileWithPassword')
279
-                         ->will($this->returnCallback(function ($input, $output, $password) {
280
-                             $fs = new Filesystem();
281
-                             $fs->dumpFile($output, 'Plain text');
282
-                         }));
278
+                            ->method('decryptFileWithPassword')
279
+                            ->will($this->returnCallback(function ($input, $output, $password) {
280
+                                $fs = new Filesystem();
281
+                                $fs->dumpFile($output, 'Plain text');
282
+                            }));
283 283
 
284 284
         $this->wrapper->decryptFileWithPassword(__DIR__.'/file.crypto', __DIR__.'/file.txt', 'SuperSecretPa$$word');
285 285
 
@@ -296,8 +296,8 @@  discard block
 block discarded – undo
296 296
     {
297 297
         try {
298 298
             $this->encryption->expects($this->once())
299
-                             ->method('decryptFileWithPassword')
300
-                             ->will($this->throwException(new WrongKeyOrModifiedCiphertextException()));
299
+                                ->method('decryptFileWithPassword')
300
+                                ->will($this->throwException(new WrongKeyOrModifiedCiphertextException()));
301 301
         } catch (BaseCryptoException $e) {
302 302
             $this->throwException(new CryptoException());
303 303
         }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
     {
119 119
         $this->encryption->expects($this->once())
120 120
                          ->method('encryptFileWithKey')
121
-                         ->will($this->returnCallback(function ($input, $output) {
121
+                         ->will($this->returnCallback(function($input, $output) {
122 122
                              $fs = new Filesystem();
123 123
                              $fs->dumpFile($output, '');
124 124
                          }));
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     {
138 138
         $this->encryption->expects($this->once())
139 139
                          ->method('decryptFileWithKey')
140
-                         ->will($this->returnCallback(function ($input, $output) {
140
+                         ->will($this->returnCallback(function($input, $output) {
141 141
                              $fs = new Filesystem();
142 142
                              $fs->dumpFile($output, 'Plain text');
143 143
                          }));
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
     {
245 245
         $this->encryption->expects($this->once())
246 246
                          ->method('encryptFileWithPassword')
247
-                         ->will($this->returnCallback(function ($input, $output, $password) {
247
+                         ->will($this->returnCallback(function($input, $output, $password) {
248 248
                              $fs = new Filesystem();
249 249
                              $fs->dumpFile($output, '');
250 250
                          }));
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
     {
277 277
         $this->encryption->expects($this->once())
278 278
                          ->method('decryptFileWithPassword')
279
-                         ->will($this->returnCallback(function ($input, $output, $password) {
279
+                         ->will($this->returnCallback(function($input, $output, $password) {
280 280
                              $fs = new Filesystem();
281 281
                              $fs->dumpFile($output, 'Plain text');
282 282
                          }));
Please login to merge, or discard this patch.
Tests/bootstrap.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
  * file that was distributed with this source code.
10 10
  */
11 11
 
12
-register_shutdown_function(function () {
12
+register_shutdown_function(function() {
13 13
     if (file_exists(__DIR__.'/key.crypto')) {
14 14
         unlink(__DIR__.'/key.crypto');
15 15
     }
Please login to merge, or discard this patch.