Completed
Push — master ( 23cd7e...7877b2 )
by Francesco
02:54
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   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     protected function setUp()
37 37
     {
38 38
         $this->encryption = $this->getMockBuilder('Mes\Security\CryptoBundle\EncryptionInterface')
39
-                                 ->getMock();
39
+                                    ->getMock();
40 40
         $this->wrapper = new EncryptionWrapper($this->encryption);
41 41
     }
42 42
 
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
     public function testEncryptWithKeyEncryptsPlaintext()
53 53
     {
54 54
         $this->encryption->expects($this->once())
55
-                         ->method('encryptWithKey')
56
-                         ->with('The quick brown fox jumps over the lazy dog', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock())
57
-                         ->will($this->returnValue('ThisIsACipherText'));
55
+                            ->method('encryptWithKey')
56
+                            ->with('The quick brown fox jumps over the lazy dog', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock())
57
+                            ->will($this->returnValue('ThisIsACipherText'));
58 58
 
59 59
         $ciphertext = $this->wrapper->encryptWithKey('The quick brown fox jumps over the lazy dog', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock());
60 60
 
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
     {
69 69
         try {
70 70
             $this->encryption->expects($this->once())
71
-                             ->method('encryptWithKey')
72
-                             ->with('The quick brown fox jumps over the lazy dog', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock())
73
-                             ->will($this->throwException(new EnvironmentIsBrokenException()));
71
+                                ->method('encryptWithKey')
72
+                                ->with('The quick brown fox jumps over the lazy dog', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock())
73
+                                ->will($this->throwException(new EnvironmentIsBrokenException()));
74 74
         } catch (EnvironmentIsBrokenException $e) {
75 75
             $this->throwException(new CryptoException());
76 76
         }
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
     public function testDecryptWithKeyDecryptsCiphertext()
85 85
     {
86 86
         $this->encryption->expects($this->once())
87
-                         ->method('decryptWithKey')
88
-                         ->with('ThisIsACipherText', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock())
89
-                         ->will($this->returnValue('The quick brown fox jumps over the lazy dog'));
87
+                            ->method('decryptWithKey')
88
+                            ->with('ThisIsACipherText', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock())
89
+                            ->will($this->returnValue('The quick brown fox jumps over the lazy dog'));
90 90
 
91 91
         $decryptedText = $this->wrapper->decryptWithKey('ThisIsACipherText', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock());
92 92
 
@@ -100,9 +100,9 @@  discard block
 block discarded – undo
100 100
     {
101 101
         try {
102 102
             $this->encryption->expects($this->once())
103
-                             ->method('decryptWithKey')
104
-                             ->with('ThisIsACipherText', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock())
105
-                             ->will($this->throwException(new BaseCryptoException()));
103
+                                ->method('decryptWithKey')
104
+                                ->with('ThisIsACipherText', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock())
105
+                                ->will($this->throwException(new BaseCryptoException()));
106 106
         } catch (BaseCryptoException $e) {
107 107
             $this->throwException(new CryptoException());
108 108
         }
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
     public function testEncryptWithKeyFileEncryptsFile()
117 117
     {
118 118
         $this->encryption->expects($this->once())
119
-                         ->method('encryptFileWithKey')
120
-                         ->will($this->returnCallback(function ($input, $output) {
121
-                             $fs = new Filesystem();
122
-                             $fs->dumpFile($output, '');
123
-                         }));
119
+                            ->method('encryptFileWithKey')
120
+                            ->will($this->returnCallback(function ($input, $output) {
121
+                                $fs = new Filesystem();
122
+                                $fs->dumpFile($output, '');
123
+                            }));
124 124
 
125 125
         $this->wrapper->encryptFileWithKey(__DIR__.'/file.txt', __DIR__.'/file.crypto', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock());
126 126
 
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
     public function testDecryptWithKeyFileDecryptsEncryptedFile()
136 136
     {
137 137
         $this->encryption->expects($this->once())
138
-                         ->method('decryptFileWithKey')
139
-                         ->will($this->returnCallback(function ($input, $output) {
140
-                             $fs = new Filesystem();
141
-                             $fs->dumpFile($output, 'Plain text');
142
-                         }));
138
+                            ->method('decryptFileWithKey')
139
+                            ->will($this->returnCallback(function ($input, $output) {
140
+                                $fs = new Filesystem();
141
+                                $fs->dumpFile($output, 'Plain text');
142
+                            }));
143 143
 
144 144
         $this->wrapper->decryptFileWithKey(__DIR__.'/file.crypto', __DIR__.'/file.txt', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock());
145 145
 
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
     {
157 157
         try {
158 158
             $this->encryption->expects($this->once())
159
-                             ->method('encryptFileWithKey')
160
-                             ->will($this->throwException(new BaseCryptoException()));
159
+                                ->method('encryptFileWithKey')
160
+                                ->will($this->throwException(new BaseCryptoException()));
161 161
         } catch (BaseCryptoException $e) {
162 162
             $this->throwException(new CryptoException());
163 163
         }
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
     {
173 173
         try {
174 174
             $this->encryption->expects($this->once())
175
-                             ->method('decryptFileWithKey')
176
-                             ->will($this->throwException(new BaseCryptoException()));
175
+                                ->method('decryptFileWithKey')
176
+                                ->will($this->throwException(new BaseCryptoException()));
177 177
         } catch (BaseCryptoException $e) {
178 178
             $this->throwException(new CryptoException());
179 179
         }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
     {
118 118
         $this->encryption->expects($this->once())
119 119
                          ->method('encryptFileWithKey')
120
-                         ->will($this->returnCallback(function ($input, $output) {
120
+                         ->will($this->returnCallback(function($input, $output) {
121 121
                              $fs = new Filesystem();
122 122
                              $fs->dumpFile($output, '');
123 123
                          }));
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
     {
137 137
         $this->encryption->expects($this->once())
138 138
                          ->method('decryptFileWithKey')
139
-                         ->will($this->returnCallback(function ($input, $output) {
139
+                         ->will($this->returnCallback(function($input, $output) {
140 140
                              $fs = new Filesystem();
141 141
                              $fs->dumpFile($output, 'Plain text');
142 142
                          }));
Please login to merge, or discard this patch.