mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-11 17:51:02 +00:00
Move test files directly under tests/ directory
This commit is contained in:
parent
a37b385c23
commit
24da70e338
117 changed files with 4 additions and 4 deletions
38
tests/Helper/CryptoProxyTest.php
Normal file
38
tests/Helper/CryptoProxyTest.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Wallabag\CoreBundle\Helper;
|
||||
|
||||
use Monolog\Handler\TestHandler;
|
||||
use Monolog\Logger;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\NullLogger;
|
||||
use Wallabag\CoreBundle\Helper\CryptoProxy;
|
||||
|
||||
class CryptoProxyTest extends TestCase
|
||||
{
|
||||
public function testCrypto()
|
||||
{
|
||||
$logHandler = new TestHandler();
|
||||
$logger = new Logger('test', [$logHandler]);
|
||||
|
||||
$crypto = new CryptoProxy(sys_get_temp_dir() . '/' . uniqid('', true) . '.txt', $logger);
|
||||
$crypted = $crypto->crypt('test');
|
||||
$decrypted = $crypto->decrypt($crypted);
|
||||
|
||||
$this->assertSame('test', $decrypted);
|
||||
|
||||
$records = $logHandler->getRecords();
|
||||
$this->assertCount(2, $records);
|
||||
$this->assertStringContainsString('Crypto: crypting value', $records[0]['message']);
|
||||
$this->assertStringContainsString('Crypto: decrypting value', $records[1]['message']);
|
||||
}
|
||||
|
||||
public function testDecryptBadValue()
|
||||
{
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$this->expectExceptionMessage('Decrypt fail');
|
||||
|
||||
$crypto = new CryptoProxy(sys_get_temp_dir() . '/' . uniqid('', true) . '.txt', new NullLogger());
|
||||
$crypto->decrypt('badvalue');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue