Last active
May 20, 2021 22:13
-
-
Save sameernyaupane/679659b3f4f24f90f03ce22ce5156c31 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Tests\Unit; | |
use App\Calculate; | |
use PHPUnit\Framework\TestCase; | |
class CalculateTest extends TestCase | |
{ | |
public function setUp() | |
{ | |
$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
Error with current version. I forked and added
: void
to the setUp function