Code Duplication    Length = 12-13 lines in 4 locations

Tests/EncryptionResourceWrapperTest.php 4 locations

@@ 80-92 (lines=13) @@
77
    /**
78
     * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException
79
     */
80
    public function testEncryptResourceWithKeyThrowsException()
81
    {
82
        try {
83
            $this->encryption->expects($this->once())
84
                             ->method('encryptResourceWithKey')
85
                             ->will($this->throwException(new BaseCryptoException()));
86
        } catch (BaseCryptoException $e) {
87
            $this->throwException(new CryptoException());
88
        }
89
90
        $this->wrapper->encryptResourceWithKey(fopen('php://stdin', 'r'), fopen('php://memory', 'wb'), $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
91
                                                                                                            ->getMock());
92
    }
93
94
    /**
95
     * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException
@@ 97-109 (lines=13) @@
94
    /**
95
     * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException
96
     */
97
    public function testDecryptResourceWithKeyThrowsException()
98
    {
99
        try {
100
            $this->encryption->expects($this->once())
101
                             ->method('decryptResourceWithKey')
102
                             ->will($this->throwException(new BaseCryptoException()));
103
        } catch (BaseCryptoException $e) {
104
            $this->throwException(new CryptoException());
105
        }
106
107
        $this->wrapper->decryptResourceWithKey(fopen('php://stdin', 'r'), fopen('php://memory', 'wb'), $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
108
                                                                                                            ->getMock());
109
    }
110
111
    /* ================================================
112
     *
@@ 143-154 (lines=12) @@
140
    /**
141
     * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException
142
     */
143
    public function testEncryptResourceWithPasswordThrowsException()
144
    {
145
        try {
146
            $this->encryption->expects($this->once())
147
                             ->method('encryptResourceWithPassword')
148
                             ->will($this->throwException(new BaseCryptoException()));
149
        } catch (BaseCryptoException $e) {
150
            $this->throwException(new CryptoException());
151
        }
152
153
        $this->wrapper->encryptResourceWithPassword(fopen('php://stdin', 'r'), fopen('php://memory', 'wb'), 'SecretPa$$word');
154
    }
155
156
    /**
157
     * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException
@@ 159-170 (lines=12) @@
156
    /**
157
     * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException
158
     */
159
    public function testDecryptResourceWithPasswordThrowsException()
160
    {
161
        try {
162
            $this->encryption->expects($this->once())
163
                             ->method('decryptResourceWithPassword')
164
                             ->will($this->throwException(new BaseCryptoException()));
165
        } catch (BaseCryptoException $e) {
166
            $this->throwException(new CryptoException());
167
        }
168
169
        $this->wrapper->decryptResourceWithPassword(fopen('php://stdin', 'r'), fopen('php://memory', 'wb'), 'SecretPa$$word');
170
    }
171
}
172