| @@ 61-75 (lines=15) @@ | ||
| 58 | /** |
|
| 59 | * @expectedException \UnexpectedValueException |
|
| 60 | */ |
|
| 61 | public function testLoadKeyThrowsExceptionBecauseKeyIsMissing() |
|
| 62 | { |
|
| 63 | $this->tempCryptoFile = __DIR__.'/../invalid_key.crypto'; |
|
| 64 | ||
| 65 | $handle = fopen($this->tempCryptoFile, 'w+'); |
|
| 66 | fwrite($handle, <<<'EOF' |
|
| 67 | secret=ThisIsASecret |
|
| 68 | EOF |
|
| 69 | ); |
|
| 70 | fclose($handle); |
|
| 71 | ||
| 72 | $loader = new CryptoLoader(); |
|
| 73 | $loader->setResource($this->tempCryptoFile); |
|
| 74 | $loader->loadKey(); |
|
| 75 | } |
|
| 76 | ||
| 77 | /** |
|
| 78 | * @expectedException \UnexpectedValueException |
|
| @@ 80-94 (lines=15) @@ | ||
| 77 | /** |
|
| 78 | * @expectedException \UnexpectedValueException |
|
| 79 | */ |
|
| 80 | public function testLoadKeyThrowsExceptionBecauseSecretIsMissing() |
|
| 81 | { |
|
| 82 | $this->tempCryptoFile = __DIR__.'/../invalid_key.crypto'; |
|
| 83 | ||
| 84 | $handle = fopen($this->tempCryptoFile, 'w+'); |
|
| 85 | fwrite($handle, <<<'EOF' |
|
| 86 | key=ThisIsAnEncodedKey |
|
| 87 | EOF |
|
| 88 | ); |
|
| 89 | fclose($handle); |
|
| 90 | ||
| 91 | $loader = new CryptoLoader(); |
|
| 92 | $loader->setResource($this->tempCryptoFile); |
|
| 93 | $loader->loadSecret(); |
|
| 94 | } |
|
| 95 | ||
| 96 | public function testLoadSecretLoadsSecret() |
|
| 97 | { |
|
| @@ 117-131 (lines=15) @@ | ||
| 114 | /** |
|
| 115 | * @expectedException \RuntimeException |
|
| 116 | */ |
|
| 117 | public function test__ConstructFailsBecauseResourceIsBadFormatted() |
|
| 118 | { |
|
| 119 | $this->tempCryptoFile = __DIR__.'/../invalid_key.crypto'; |
|
| 120 | ||
| 121 | $handle = fopen($this->tempCryptoFile, 'w+'); |
|
| 122 | fwrite($handle, <<<'EOF' |
|
| 123 | key:ThisIsAKey |
|
| 124 | secret:ThisIsASecret |
|
| 125 | EOF |
|
| 126 | ); |
|
| 127 | fclose($handle); |
|
| 128 | ||
| 129 | $loader = new CryptoLoader(); |
|
| 130 | $loader->setResource($this->tempCryptoFile); |
|
| 131 | } |
|
| 132 | } |
|
| 133 | ||