cryptStub = new CryptTraitStub(); } public function testEncryptDecryptWithPassword() { $this->cryptStub->setEncryptionKey(base64_encode(random_bytes(36))); $this->encryptDecrypt(); } public function testEncryptDecryptWithKey() { $this->cryptStub->setEncryptionKey(Key::createNewRandomKey()); $this->encryptDecrypt(); } private function encryptDecrypt() { $payload = 'alex loves whisky'; $encrypted = $this->cryptStub->doEncrypt($payload); $plainText = $this->cryptStub->doDecrypt($encrypted); $this->assertNotEquals($payload, $encrypted); $this->assertEquals($payload, $plainText); } }