CollisionTest.php 10.65 KiB
<?php
namespace Tests\Collision;
use PHPUnit\Framework\TestCase;
use App\Collision\Collision;
class CollisionTest extends TestCase
    /**
     * @dataProvider circleRectangleData
    public function testCircleRectangle(int $c_radius, int $c_x, int $c_y, int $r_w, int $r_h, int $r_x, int $r_y, bool $expected)
        $result = Collision::circleRectangle($c_radius, $c_x, $c_y, $r_w, $r_h, $r_x, $r_y);
        $this->assertEquals($expected, $result);
    public function circleRectangleData()
        return [
                1, // circle radius
                0, // circle x
                0, // circle y
                1, // rectangle width
                1, // rectangle height
                100, // rectangle x
                100, // rectangle y,
                false // expected collison
                10, // circle radius
                250, // circle x
                250, // circle y
                200, // rectangle width
                200, // rectangle height
                0, // rectangle x
                0, // rectangle y,
                false // expected collison
                10, // circle radius
                10, // circle x
                10, // circle y
                10, // rectangle width
                10, // rectangle height
                0, // rectangle x
                0, // rectangle y,
                true // expected collison
                10, // circle radius
                200, // circle x
                50, // circle y
                200, // rectangle width
                200, // rectangle height
                0, // rectangle x
                0, // rectangle y,
                true // expected collison
     /**
     * @dataProvider circleWorldData
    public function testCircleWorld(int $c_radius, int $c_x, int $c_y, int $w_w, int $w_h, int $w_x, int $w_y, bool $expected)