Skip to content

Instantly share code, notes, and snippets.

@tim-andes
Forked from sameernyaupane/CalculateTest.php
Created May 20, 2021 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tim-andes/99da205f6127f608759edb6b1d96c8f4 to your computer and use it in GitHub Desktop.
Save tim-andes/99da205f6127f608759edb6b1d96c8f4 to your computer and use it in GitHub Desktop.
<?php
namespace Tests\Unit;
use App\Calculate;
use PHPUnit\Framework\TestCase;
class CalculateTest extends TestCase
{
public function setUp(): void
{
$this->calculate = new Calculate();
}
public function test_areaOfSquare_WhenCalledWithLength2_Return4()
{
$length = 2;
$response = $this->calculate->areaOfSquare($length);
$this->assertTrue(is_int($response));
$this->assertEquals(4, $response);
}
public function test_areaOfSquare_WhenCalledWithLength6_Return36()
{
$length = 6;
$response = $this->calculate->areaOfSquare($length);
$this->assertTrue(is_int($response));
$this->assertEquals(36, $response);
}
public function test_areaOfSquare_WhenCalledWithoutLength_ThrowAnException()
{
$this->expectException('ArgumentCountError');
$this->expectExceptionMessage('Too few arguments to function');
$this->calculate->areaOfSquare();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment