Skip to content

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
- переходим на нэймспейс `AJUR\Toolkit`
  • Loading branch information
Karel Wintersky committed Jul 3, 2024
1 parent 25c0f0f commit 1a6d6ec
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
},
"autoload": {
"psr-4": {
"Gumlet\\": "lib/"
"AJUR\\Toolkit\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Gumlet\\": "test/"
"AJUR\\Toolkit\\": "tests/"
}
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ setup_env: ##@localhost Setup environment at localhost
@echo Setting up local environment
@composer install

phpunit: ##@localhost Make tests
test: ##@localhost Make tests
@./vendor/bin/phpunit

# ------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion lib/ImageResize.php → src/ImageResize.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Gumlet;
namespace AJUR\Toolkit;

use Exception;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Gumlet;
namespace AJUR\Toolkit;

/**
* PHP Exception used in the ImageResize class
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Gumlet;
namespace AJUR\Toolkit;

interface ImageResizeInterface
{
Expand Down
9 changes: 4 additions & 5 deletions tests/ImageResizeExceptionTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

use \Gumlet\ImageResize;
use \Gumlet\ImageResizeException;
use AJUR\Toolkit\ImageResizeException;
use \PHPUnit\Framework\TestCase;

class ImageResizeExceptionTest extends TestCase
Expand All @@ -11,15 +10,15 @@ public function testExceptionEmpty()
$e = new ImageResizeException();

$this->assertEquals("", $e->getMessage());
$this->assertInstanceOf('\Gumlet\ImageResizeException', $e);
$this->assertInstanceOf('AJUR\Toolkit\ImageResizeException', $e);
}

public function testExceptionMessage()
{
$e = new ImageResizeException("General error");

$this->assertEquals("General error", $e->getMessage());
$this->assertInstanceOf('\Gumlet\ImageResizeException', $e);
$this->assertInstanceOf('AJUR\Toolkit\ImageResizeException', $e);
}

public function testExceptionExtending()
Expand All @@ -35,7 +34,7 @@ public function testExceptionThrown()
throw new ImageResizeException("General error");
} catch (\Exception $e) {
$this->assertEquals("General error", $e->getMessage());
$this->assertInstanceOf('\Gumlet\ImageResizeException', $e);
$this->assertInstanceOf('AJUR\Toolkit\ImageResizeException', $e);
return;
}
$this->fail();
Expand Down
45 changes: 23 additions & 22 deletions tests/ImageResizeTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

use \Gumlet\ImageResize;
use \Gumlet\ImageResizeException;

use AJUR\Toolkit\ImageResize;
use AJUR\Toolkit\ImageResizeException;
use \PHPUnit\Framework\TestCase;

class ImageResizeTest extends TestCase
Expand All @@ -28,7 +29,7 @@ public function testLoadGif()
$resize = new ImageResize($image);

$this->assertEquals(IMAGETYPE_GIF, $resize->source_type);
$this->assertInstanceOf('\Gumlet\ImageResize', $resize);
$this->assertInstanceOf('\AJUR\Toolkit\ImageResize', $resize);
}

public function testLoadJpg()
Expand All @@ -37,7 +38,7 @@ public function testLoadJpg()
$resize = new ImageResize($image);

$this->assertEquals(IMAGETYPE_JPEG, $resize->source_type);
$this->assertInstanceOf('\Gumlet\ImageResize', $resize);
$this->assertInstanceOf('\AJUR\Toolkit\ImageResize', $resize);
}

public function testLoadIgnoreXmpExifJpg()
Expand All @@ -46,7 +47,7 @@ public function testLoadIgnoreXmpExifJpg()
$resize = new ImageResize($image);

$this->assertEquals(IMAGETYPE_JPEG, $resize->source_type);
$this->assertInstanceOf('\Gumlet\ImageResize', $resize);
$this->assertInstanceOf('\AJUR\Toolkit\ImageResize', $resize);
}

public function testLoadPng()
Expand All @@ -55,7 +56,7 @@ public function testLoadPng()
$resize = new ImageResize($image);

$this->assertEquals(IMAGETYPE_PNG, $resize->source_type);
$this->assertInstanceOf('\Gumlet\ImageResize', $resize);
$this->assertInstanceOf('\AJUR\Toolkit\ImageResize', $resize);
}

public function testLoadWebp()
Expand All @@ -64,23 +65,23 @@ public function testLoadWebp()
$resize = new ImageResize($image);

$this->assertEquals(IMAGETYPE_WEBP, $resize->source_type);
$this->assertInstanceOf('\Gumlet\ImageResize', $resize);
$this->assertInstanceOf('\AJUR\Toolkit\ImageResize', $resize);
}

public function testLoadString()
{
$resize = ImageResize::createFromString(base64_decode($this->image_string));

$this->assertEquals(IMAGETYPE_GIF, $resize->source_type);
$this->assertInstanceOf('\Gumlet\ImageResize', $resize);
$this->assertInstanceOf('\AJUR\Toolkit\ImageResize', $resize);
}

public function testLoadRfc2397()
{
$resize = new ImageResize($this->data_url);

$this->assertEquals(IMAGETYPE_GIF, $resize->source_type);
$this->assertInstanceOf('\Gumlet\ImageResize', $resize);
$this->assertInstanceOf('\AJUR\Toolkit\ImageResize', $resize);
}

public function testAddFilter()
Expand All @@ -89,7 +90,7 @@ public function testAddFilter()
$resize = new ImageResize($image);
$filename = $this->getTempFile();

$this->assertInstanceOf('\Gumlet\ImageResize', $resize->addFilter('imagefilter'));
$this->assertInstanceOf('\AJUR\Toolkit\ImageResize', $resize->addFilter('imagefilter'));
}

public function testApplyFilter()
Expand All @@ -99,7 +100,7 @@ public function testApplyFilter()
$resize->addFilter('imagefilter');
$filename = $this->getTempFile();

$this->assertInstanceOf('\Gumlet\ImageResize', $resize->save($filename));
$this->assertInstanceOf('\AJUR\Toolkit\ImageResize', $resize->save($filename));
}

/**
Expand All @@ -109,29 +110,29 @@ public function testApplyFilter()
public function testLoadNoFile()
{
$this->expectExceptionMessage("No filename given");
$this->expectException(\Gumlet\ImageResizeException::class);
$this->expectException(ImageResizeException::class);
new ImageResize(null);
}

public function testLoadUnsupportedFile()
{
$this->expectExceptionMessage("Gumlet\ImageResize ERROR: Could not read file");
$this->expectException(\Gumlet\ImageResizeException::class);
$this->expectExceptionMessage("AJUR\Toolkit\ImageResize ERROR: Could not read file");
$this->expectException(ImageResizeException::class);
new ImageResize(__FILE__);
}

public function testLoadUnsupportedFileString()
{
$this->expectExceptionMessage("image_data must not be empty");
$this->expectException(\Gumlet\ImageResizeException::class);
$this->expectException(ImageResizeException::class);
ImageResize::createFromString('');
}

/*public function testLoadUnsupportedImage()
{
// хер его знает почему не работает тест...
// $this->expectExceptionMessage("Gumlet\ImageResize ERROR: Unsupported image type");
// $this->expectException(\Gumlet\ImageResizeException::class);
$this->expectExceptionMessage("AJUR\Toolkit\ImageResize ERROR: Unsupported image type");
$this->expectException(\AJUR\Toolkit\ImageResizeException::class);
$filename = $this->getTempFile();
$image = fopen($filename, 'w');
Expand All @@ -143,8 +144,8 @@ public function testLoadUnsupportedFileString()

/*public function testInvalidString()
{
$this->expectExceptionMessage("Gumlet\ImageResize ERROR: Unsupported image type");
$this->expectException(\Gumlet\ImageResizeException::class);
$this->expectExceptionMessage("AJUR\Toolkit\ImageResize ERROR: Unsupported image type");
$this->expectException(\AJUR\Toolkit\ImageResizeException::class);
ImageResize::createFromString(base64_decode($this->unsupported_image));
}*/

Expand Down Expand Up @@ -317,23 +318,23 @@ public function testCropPosition()

$resize->crop(50, 50, false, $resize::CROPRIGHT);

$reflection_class = new ReflectionClass('\Gumlet\ImageResize');
$reflection_class = new ReflectionClass('\AJUR\Toolkit\ImageResize');
$source_x = $reflection_class->getProperty('source_x');
$source_x->setAccessible(true);

$this->assertEquals(100, $source_x->getValue($resize));

$resize->crop(50, 50, false, $resize::CROPCENTRE);

$reflection_class = new ReflectionClass('\Gumlet\ImageResize');
$reflection_class = new ReflectionClass('\AJUR\Toolkit\ImageResize');
$source_x = $reflection_class->getProperty('source_x');
$source_x->setAccessible(true);

$this->assertEquals(50, $source_x->getValue($resize));

$resize->crop(50, 50, false, $resize::CROPTOPCENTER);

$reflection_class = new ReflectionClass('\Gumlet\ImageResize');
$reflection_class = new ReflectionClass('\AJUR\Toolkit\ImageResize');
$source_x = $reflection_class->getProperty('source_x');
$source_x->setAccessible(true);

Expand Down

0 comments on commit 1a6d6ec

Please sign in to comment.