mirror of
https://github.com/Intervention/image.git
synced 2025-08-25 14:50:48 +02:00
PHPUnit 10 Migration (#1302)
* Bump PHPUnit dependencies * Set return type of base TestCase methods From the [PHPUnit 8 release notes][1], the `TestCase` methods below now declare a `void` return type: - `setUpBeforeClass()` - `setUp()` - `assertPreConditions()` - `assertPostConditions()` - `tearDown()` - `tearDownAfterClass()` - `onNotSuccessfulTest()` [1]: https://phpunit.de/announcements/phpunit-8.html * Ignore PHPUnit cache folder * Adopt PHP attributes in test classes * Declare data providers as `static` * Add return types to test methods * Define test classes as `final` * Migrate phpunit.xml to phpunit 10 * Correct phpunit attribute class name * Rename base test class * Restructure test folders * Fix test image paths * Only set rules for php files in .editorconfig * Remove php unit flag in local test env --------- Co-authored-by: Shift <shift@laravelshift.com>
This commit is contained in:
91
tests/Unit/Geometry/PointTest.php
Normal file
91
tests/Unit/Geometry/PointTest.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Tests\Unit\Geometry;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use Intervention\Image\Geometry\Point;
|
||||
use Intervention\Image\Tests\BaseTestCase;
|
||||
|
||||
#[CoversClass(\Intervention\Image\Geometry\Point::class)]
|
||||
final class PointTest extends BaseTestCase
|
||||
{
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$point = new Point();
|
||||
$this->assertInstanceOf(Point::class, $point);
|
||||
$this->assertEquals(0, $point->x());
|
||||
$this->assertEquals(0, $point->y());
|
||||
}
|
||||
|
||||
public function testConstructorWithParameters(): void
|
||||
{
|
||||
$point = new Point(40, 50);
|
||||
$this->assertInstanceOf(Point::class, $point);
|
||||
$this->assertEquals(40, $point->x());
|
||||
$this->assertEquals(50, $point->y());
|
||||
}
|
||||
|
||||
public function testGetSetX(): void
|
||||
{
|
||||
$point = new Point(0, 0);
|
||||
$point->setX(100);
|
||||
$this->assertEquals(100, $point->x());
|
||||
$this->assertEquals(0, $point->y());
|
||||
}
|
||||
|
||||
public function testGetSetY(): void
|
||||
{
|
||||
$point = new Point(0, 0);
|
||||
$point->setY(100);
|
||||
$this->assertEquals(0, $point->x());
|
||||
$this->assertEquals(100, $point->y());
|
||||
}
|
||||
|
||||
public function testmoveX(): void
|
||||
{
|
||||
$point = new Point(50, 50);
|
||||
$point->moveX(100);
|
||||
$this->assertEquals(150, $point->x());
|
||||
$this->assertEquals(50, $point->y());
|
||||
}
|
||||
|
||||
public function testmoveY(): void
|
||||
{
|
||||
$point = new Point(50, 50);
|
||||
$point->moveY(100);
|
||||
$this->assertEquals(50, $point->x());
|
||||
$this->assertEquals(150, $point->y());
|
||||
}
|
||||
|
||||
public function testSetPosition(): void
|
||||
{
|
||||
$point = new Point(0, 0);
|
||||
$point->setPosition(100, 200);
|
||||
$this->assertEquals(100, $point->x());
|
||||
$this->assertEquals(200, $point->y());
|
||||
}
|
||||
|
||||
public function testRotate(): void
|
||||
{
|
||||
$point = new Point(30, 0);
|
||||
$point->rotate(90, new Point(0, 0));
|
||||
$this->assertEquals(0, $point->x());
|
||||
$this->assertEquals(30, $point->y());
|
||||
|
||||
$point->rotate(90, new Point(0, 0));
|
||||
$this->assertEquals(-30, $point->x());
|
||||
$this->assertEquals(0, $point->y());
|
||||
|
||||
$point = new Point(300, 200);
|
||||
$point->rotate(90, new Point(0, 0));
|
||||
$this->assertEquals(-200, $point->x());
|
||||
$this->assertEquals(300, $point->y());
|
||||
|
||||
$point = new Point(0, 74);
|
||||
$point->rotate(45, new Point(0, 0));
|
||||
$this->assertEquals(-52, $point->x());
|
||||
$this->assertEquals(52, $point->y());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user