Test Setup Failed
Push — master ( 95e1f1...f2603a )
by Francesco
03:53
created
Tests/EncryptionWrapperTest.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -36,13 +36,13 @@  discard block
 block discarded – undo
36 36
     public function testEncryptEncryptsPlaintext()
37 37
     {
38 38
         $this->encryption->expects($this->once())
39
-                         ->method('encrypt')
40
-                         ->with('The quick brown fox jumps over the lazy dog', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
39
+                            ->method('encrypt')
40
+                            ->with('The quick brown fox jumps over the lazy dog', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
41 41
                                                                                     ->getMock())
42
-                         ->will($this->returnValue('ThisIsACipherText'));
42
+                            ->will($this->returnValue('ThisIsACipherText'));
43 43
 
44 44
         $ciphertext = $this->wrapper->encrypt('The quick brown fox jumps over the lazy dog', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
45
-                                                                                                  ->getMock());
45
+                                                                                                    ->getMock());
46 46
 
47 47
         $this->assertTrue(ctype_print($ciphertext), 'is printable');
48 48
     }
@@ -54,10 +54,10 @@  discard block
 block discarded – undo
54 54
     {
55 55
         try {
56 56
             $this->encryption->expects($this->once())
57
-                             ->method('encrypt')
58
-                             ->with('The quick brown fox jumps over the lazy dog', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
57
+                                ->method('encrypt')
58
+                                ->with('The quick brown fox jumps over the lazy dog', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
59 59
                                                                                         ->getMock())
60
-                             ->will($this->throwException(new EnvironmentIsBrokenException()));
60
+                                ->will($this->throwException(new EnvironmentIsBrokenException()));
61 61
         } catch (EnvironmentIsBrokenException $e) {
62 62
             $this->throwException(new CryptoException());
63 63
         }
@@ -69,13 +69,13 @@  discard block
 block discarded – undo
69 69
     public function testDecryptDecryptsCiphertext()
70 70
     {
71 71
         $this->encryption->expects($this->once())
72
-                         ->method('decrypt')
73
-                         ->with('ThisIsACipherText', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
74
-                                                          ->getMock())
75
-                         ->will($this->returnValue('The quick brown fox jumps over the lazy dog'));
72
+                            ->method('decrypt')
73
+                            ->with('ThisIsACipherText', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
74
+                                                            ->getMock())
75
+                            ->will($this->returnValue('The quick brown fox jumps over the lazy dog'));
76 76
 
77 77
         $decryptedText = $this->wrapper->decrypt('ThisIsACipherText', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
78
-                                                                           ->getMock());
78
+                                                                            ->getMock());
79 79
 
80 80
         $this->assertSame('The quick brown fox jumps over the lazy dog', $decryptedText);
81 81
     }
@@ -87,29 +87,29 @@  discard block
 block discarded – undo
87 87
     {
88 88
         try {
89 89
             $this->encryption->expects($this->once())
90
-                             ->method('decrypt')
91
-                             ->with('ThisIsACipherText', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
92
-                                                              ->getMock())
93
-                             ->will($this->throwException(new BaseCryptoException()));
90
+                                ->method('decrypt')
91
+                                ->with('ThisIsACipherText', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
92
+                                                                ->getMock())
93
+                                ->will($this->throwException(new BaseCryptoException()));
94 94
         } catch (BaseCryptoException $e) {
95 95
             $this->throwException(new CryptoException());
96 96
         }
97 97
 
98 98
         $this->wrapper->decrypt('ThisIsACipherText', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
99
-                                                          ->getMock());
99
+                                                            ->getMock());
100 100
     }
101 101
 
102 102
     public function testEncryptFileEncryptsFile()
103 103
     {
104 104
         $this->encryption->expects($this->once())
105
-                         ->method('encryptFile')
106
-                         ->will($this->returnCallback(function ($input, $output) {
107
-                             $fs = new Filesystem();
108
-                             $fs->dumpFile($output, '');
109
-                         }));
105
+                            ->method('encryptFile')
106
+                            ->will($this->returnCallback(function ($input, $output) {
107
+                                $fs = new Filesystem();
108
+                                $fs->dumpFile($output, '');
109
+                            }));
110 110
 
111 111
         $this->wrapper->encryptFile(__DIR__.'/file.txt', __DIR__.'/file.crypto', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
112
-                                                                                          ->getMock());
112
+                                                                                            ->getMock());
113 113
 
114 114
         $this->assertFileExists(__DIR__.'/file.crypto');
115 115
 
@@ -119,14 +119,14 @@  discard block
 block discarded – undo
119 119
     public function testDecryptFileDecryptsEncryptedFile()
120 120
     {
121 121
         $this->encryption->expects($this->once())
122
-                         ->method('decryptFile')
123
-                         ->will($this->returnCallback(function ($input, $output) {
124
-                             $fs = new Filesystem();
125
-                             $fs->dumpFile($output, 'Plain text');
126
-                         }));
122
+                            ->method('decryptFile')
123
+                            ->will($this->returnCallback(function ($input, $output) {
124
+                                $fs = new Filesystem();
125
+                                $fs->dumpFile($output, 'Plain text');
126
+                            }));
127 127
 
128 128
         $this->wrapper->decryptFile(__DIR__.'/file.crypto', __DIR__.'/file.txt', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
129
-                                                                                          ->getMock());
129
+                                                                                            ->getMock());
130 130
 
131 131
         $this->assertFileExists(__DIR__.'/file.txt');
132 132
         $this->assertContains('Plain text', file_get_contents(__DIR__.'/file.txt'));
@@ -141,14 +141,14 @@  discard block
 block discarded – undo
141 141
     {
142 142
         try {
143 143
             $this->encryption->expects($this->once())
144
-                             ->method('encryptFile')
145
-                             ->will($this->throwException(new BaseCryptoException()));
144
+                                ->method('encryptFile')
145
+                                ->will($this->throwException(new BaseCryptoException()));
146 146
         } catch (BaseCryptoException $e) {
147 147
             $this->throwException(new CryptoException());
148 148
         }
149 149
 
150 150
         $this->wrapper->encryptFile(__DIR__.'/file.txt', __DIR__.'/file.crypto', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
151
-                                                                                          ->getMock());
151
+                                                                                            ->getMock());
152 152
     }
153 153
 
154 154
     /**
@@ -158,20 +158,20 @@  discard block
 block discarded – undo
158 158
     {
159 159
         try {
160 160
             $this->encryption->expects($this->once())
161
-                             ->method('decryptFile')
162
-                             ->will($this->throwException(new BaseCryptoException()));
161
+                                ->method('decryptFile')
162
+                                ->will($this->throwException(new BaseCryptoException()));
163 163
         } catch (BaseCryptoException $e) {
164 164
             $this->throwException(new CryptoException());
165 165
         }
166 166
 
167 167
         $this->wrapper->decryptFile(__DIR__.'/file.crypto', __DIR__.'/file.txt', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
168
-                                                                                          ->getMock());
168
+                                                                                            ->getMock());
169 169
     }
170 170
 
171 171
     protected function setUp()
172 172
     {
173 173
         $this->encryption = $this->getMockBuilder('Mes\Security\CryptoBundle\EncryptionInterface')
174
-                                 ->getMock();
174
+                                    ->getMock();
175 175
         $this->wrapper = new EncryptionWrapper($this->encryption);
176 176
     }
177 177
 
Please login to merge, or discard this patch.
Tests/KeyManagerWrapperTest.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
     public function testGenerateCreatesKey()
38 38
     {
39 39
         $this->keyManager->expects($this->once())
40
-                         ->method('generate')
41
-                         ->with(null)
42
-                         ->will($this->returnValue($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
40
+                            ->method('generate')
41
+                            ->with(null)
42
+                            ->will($this->returnValue($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
43 43
                                                         ->getMock()));
44 44
 
45 45
         $key = $this->wrapper->generate();
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
     {
55 55
         try {
56 56
             $this->keyManager->expects($this->once())
57
-                             ->method('generate')
58
-                             ->with(null)
59
-                             ->will($this->throwException(new EnvironmentIsBrokenException()));
57
+                                ->method('generate')
58
+                                ->with(null)
59
+                                ->will($this->throwException(new EnvironmentIsBrokenException()));
60 60
         } catch (EnvironmentIsBrokenException $ex) {
61 61
             $this->throwException(new CryptoException());
62 62
         }
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
         $secret = 'ThisIsASecretPassword';
71 71
 
72 72
         $this->keyManager->expects($this->once())
73
-                         ->method('generateFromAscii')
74
-                         ->with($key_encoded, $secret)
75
-                         ->will($this->returnValue($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
73
+                            ->method('generateFromAscii')
74
+                            ->with($key_encoded, $secret)
75
+                            ->will($this->returnValue($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
76 76
                                                         ->getMock()));
77 77
 
78 78
         $key = $this->wrapper->generateFromAscii($key_encoded, $secret);
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 
91 91
         try {
92 92
             $this->keyManager->expects($this->once())
93
-                             ->method('generateFromAscii')
94
-                             ->with($key_encoded, $secret)
95
-                             ->will($this->throwException(new BaseCryptoException()));
93
+                                ->method('generateFromAscii')
94
+                                ->with($key_encoded, $secret)
95
+                                ->will($this->throwException(new BaseCryptoException()));
96 96
         } catch (CryptoException $ex) {
97 97
             $this->throwException(new CryptoException());
98 98
         }
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
     public function testGetKeyReadsKey()
104 104
     {
105 105
         $this->keyManager->expects($this->once())
106
-                         ->method('getKey')
107
-                         ->will($this->returnValue($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
106
+                            ->method('getKey')
107
+                            ->will($this->returnValue($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
108 108
                                                         ->getMock()));
109 109
 
110 110
         $key = $this->wrapper->getKey();
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
     public function testSetKeyStoresKey()
116 116
     {
117 117
         $this->keyManager->expects($this->once())
118
-                         ->method('setKey')
119
-                         ->with($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
120
-                                     ->getMock());
118
+                            ->method('setKey')
119
+                            ->with($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
120
+                                        ->getMock());
121 121
 
122 122
         $this->wrapper->setKey($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
123 123
                                     ->getMock());
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
     public function testSetSecretStoresSecret()
127 127
     {
128 128
         $this->keyManager->expects($this->once())
129
-                         ->method('setSecret')
130
-                         ->with('ThisIsASecret');
129
+                            ->method('setSecret')
130
+                            ->with('ThisIsASecret');
131 131
 
132 132
         $this->wrapper->setSecret('ThisIsASecret');
133 133
     }
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
     public function testGetSecretReadsSecret()
136 136
     {
137 137
         $this->keyManager->expects($this->once())
138
-                         ->method('getSecret')
139
-                         ->will($this->returnValue('ThisIsYourSecret'));
138
+                            ->method('getSecret')
139
+                            ->will($this->returnValue('ThisIsYourSecret'));
140 140
 
141 141
         $secret = $this->wrapper->getSecret();
142 142
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
     protected function setUp()
147 147
     {
148 148
         $this->keyManager = $this->getMockBuilder('\Mes\Security\CryptoBundle\KeyManagerInterface')
149
-                                 ->getMock();
149
+                                    ->getMock();
150 150
         $this->wrapper = new KeyManagerWrapper($this->keyManager);
151 151
     }
152 152
 
Please login to merge, or discard this patch.
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.