Fix unit tests that don't work in PHP 7.2

This commit is contained in:
Kijin Sung 2017-12-09 03:00:51 +09:00
parent 3feaf36c23
commit d7a3e1bc26
2 changed files with 19 additions and 13 deletions

View file

@ -31,19 +31,19 @@ class MailTest extends \Codeception\TestCase\Test
$mail->setFrom('devops@rhymix.org', 'Rhymix Developers');
$this->assertEquals('Rhymix Developers <devops@rhymix.org>', $mail->getFrom());
$this->assertEquals(0, count($mail->message->getTo()));
$this->assertEquals(null, $mail->message->getTo());
$mail->addTo('whoever@rhymix.org', 'Name');
$this->assertEquals(array('whoever@rhymix.org' => 'Name'), $mail->message->getTo());
$this->assertEquals(0, count($mail->message->getCc()));
$this->assertEquals(null, $mail->message->getCc());
$mail->addCc('whatever@rhymix.org', 'Nick');
$this->assertEquals(array('whatever@rhymix.org' => 'Nick'), $mail->message->getCc());
$this->assertEquals(0, count($mail->message->getBcc()));
$this->assertEquals(null, $mail->message->getBcc());
$mail->addBcc('wherever@rhymix.org', 'User');
$this->assertEquals(array('wherever@rhymix.org' => 'User'), $mail->message->getBcc());
$this->assertEquals(0, count($mail->message->getReplyTo()));
$this->assertEquals(null, $mail->message->getReplyTo());
$mail->setReplyTo('replyto@rhymix.org');
$this->assertEquals(array('replyto@rhymix.org' => ''), $mail->message->getReplyTo());
@ -151,7 +151,7 @@ class MailTest extends \Codeception\TestCase\Test
$mail->setReceiptor('Another Recipient', 'whatever@rhymix.org');
$this->assertEquals('Another Recipient <whatever@rhymix.org>', $mail->getReceiptor());
$this->assertEquals(1, count($mail->message->getTo()));
$this->assertEquals(0, count($mail->message->getCc()));
$this->assertEquals(null, $mail->message->getCc());
$mail->setBcc('bcc-1@rhymix.org');
$mail->setBcc('bcc-2@rhymix.org');

View file

@ -36,16 +36,22 @@ class SecurityTest extends \Codeception\TestCase\Test
$this->assertEquals($plaintext, $decrypted);
// Encryption with defuse/php-encryption and decryption with CryptoCompat.
$encrypted = Rhymix\Framework\Security::encrypt($plaintext);
$this->assertNotEquals(false, $encrypted);
$decrypted = Rhymix\Framework\Security::decrypt($encrypted, null, true);
$this->assertEquals($plaintext, $decrypted);
if (function_exists('mcrypt_decrypt'))
{
$encrypted = Rhymix\Framework\Security::encrypt($plaintext);
$this->assertNotEquals(false, $encrypted);
$decrypted = Rhymix\Framework\Security::decrypt($encrypted, null, true);
$this->assertEquals($plaintext, $decrypted);
}
// Encryption with CryptoCompat and decryption with defuse/php-encryption.
$encrypted = Rhymix\Framework\Security::encrypt($plaintext, null, true);
$this->assertNotEquals(false, $encrypted);
$decrypted = Rhymix\Framework\Security::decrypt($encrypted);
$this->assertEquals($plaintext, $decrypted);
if (function_exists('mcrypt_encrypt'))
{
$encrypted = Rhymix\Framework\Security::encrypt($plaintext, null, true);
$this->assertNotEquals(false, $encrypted);
$decrypted = Rhymix\Framework\Security::decrypt($encrypted);
$this->assertEquals($plaintext, $decrypted);
}
// Test invalid ciphertext.
$decrypted = Rhymix\Framework\Security::decrypt('1234' . substr($encrypted, 4));