Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
cmb69 committed Mar 22, 2023
1 parent 912f5e6 commit 0c9a96d
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions tests/VisualCaptchaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,51 +21,51 @@

namespace Cryptographp;

use PHPUnit\Framework\TestCase;
use org\bovigo\vfs\vfsStream;
use PHPUnit\Framework\TestCase;

class VisualCaptchaTest extends TestCase
{
public function setUp(): void
{
vfsStream::setup('test');
mkdir(vfsStream::url('test/images'), 0777, true);
vfsStream::setup("root");
mkdir("vfs://root/images/", 0777, true);
}

public function testCreateImage()
{
$sut = new FakeVisualCaptcha(vfsStream::url('test/images/'), '../cryptographp/fonts', $this->conf());
$sut = new FakeVisualCaptcha("vfs://root/images/", '../cryptographp/fonts', $this->conf());
$actual = $sut->createImage('ABCD');
$this->assertImageEquals('image', $actual);
}

// public function testCreateErrorImage()
// {
// $sut = new FakeVisualCaptcha(vfsStream::url('test/images/'), '../cryptographp/fonts', $this->conf());
// $sut = new FakeVisualCaptcha("vfs://root/images/", '../cryptographp/fonts', $this->conf());
// $actual = $sut->createErrorImage('Cookies must be enabled!');
// $this->assertImageEquals('error_image', $actual);
// }

public function testNoiseAbove()
{
$config = ['noise_above' => 'true'] + $this->conf();
$sut = new FakeVisualCaptcha(vfsStream::url('test/images/'), '../cryptographp/fonts', $config);
$sut = new FakeVisualCaptcha("vfs://root/images/", '../cryptographp/fonts', $config);
$actual = $sut->createImage('ABCD');
$this->assertImageEquals('noise_above', $actual);
}

public function testCryptGrayScale()
{
$config = ['crypt_gray_scale' => 'true'] + $this->conf();
$sut = new FakeVisualCaptcha(vfsStream::url('test/images/'), '../cryptographp/fonts', $config);
$sut = new FakeVisualCaptcha("vfs://root/images/", '../cryptographp/fonts', $config);
$actual = $sut->createImage('ABCD');
$this->assertImageEquals('gray_scale', $actual);
}

public function testCryptGaussianBlur()
{
$config = ['crypt_gaussian_blur' => 'true'] + $this->conf();
$sut = new FakeVisualCaptcha(vfsStream::url('test/images/'), '../cryptographp/fonts', $config);
$sut = new FakeVisualCaptcha("vfs://root/images/", '../cryptographp/fonts', $config);
$actual = $sut->createImage('ABCD');
$this->assertImageEquals('gaussian_blur', $actual);
}
Expand All @@ -74,7 +74,7 @@ public function testCryptGaussianBlur()
public function testBgImage(string $type)
{
$config = ['bg_image' => "bg.$type"] + $this->conf();
$sut = new FakeVisualCaptcha(vfsStream::url('test/images/'), '../cryptographp/fonts', $config);
$sut = new FakeVisualCaptcha("vfs://root/images/", '../cryptographp/fonts', $config);
$this->createYellowBackgroundImage($type);
$actual = $sut->createImage('ABCD');
$this->assertImageEquals("bg_image", $actual);
Expand All @@ -92,7 +92,7 @@ public function bgImages(): array
public function testBgImages()
{
$config = ['bg_image' => "."] + $this->conf();
$sut = new FakeVisualCaptcha(vfsStream::url('test/images/'), '../cryptographp/fonts', $config);
$sut = new FakeVisualCaptcha("vfs://root/images/", '../cryptographp/fonts', $config);
$this->createYellowBackgroundImage('png');
$this->createYellowBackgroundImage('gif');
$actual = $sut->createImage('ABCD');
Expand All @@ -104,14 +104,14 @@ private function createYellowBackgroundImage(string $type)
$backgroundImage = imagecreate(130, 40);
imagecolorallocate($backgroundImage, 255, 255, 0);
$writeImage = "image$type";
$writeImage($backgroundImage, vfsStream::url("test/images/bg.$type"));
$writeImage($backgroundImage, "vfs://root/images/bg.$type");
}

/** @dataProvider noiseColors */
public function testNoiseColor(string $kind, string $expected)
{
$config = ['noise_color' => $kind] + $this->conf();
$sut = new FakeVisualCaptcha(vfsStream::url('test/images/'), '../cryptographp/fonts', $config);
$sut = new FakeVisualCaptcha("vfs://root/images/", '../cryptographp/fonts', $config);
$actual = $sut->createImage('ABCD');
$this->assertImageEquals($expected, $actual);
}
Expand All @@ -129,7 +129,7 @@ public function noiseColors(): array
// */
// public function testWordwrapInErrorImage()
// {
// $sut = new FakeVisualCaptcha(vfsStream::url('test/images/'), '../cryptographp/fonts', self::CONFIG);
// $sut = new FakeVisualCaptcha("vfs://root/images/", '../cryptographp/fonts', self::CONFIG);
// $actual = $sut->createErrorImage('Перезагрузка слишком быстро!');
// $this->assertImageEquals('word_wrap_in_error', $actual);
// }
Expand Down

0 comments on commit 0c9a96d

Please sign in to comment.