Skip to content

Instantly share code, notes, and snippets.

@tim-andes
Forked from sameernyaupane/MathTest.php
Created May 24, 2021 17:23
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/f53b075a4d43e46510a69ce018546467 to your computer and use it in GitHub Desktop.
Save tim-andes/f53b075a4d43e46510a69ce018546467 to your computer and use it in GitHub Desktop.
<?php
namespace Tests\Unit;
use App\Math;
use Mockery as m;
use Mockery\Adapter\Phpunit\MockeryTestCase;
class MathTest extends MockeryTestCase
{
public function setUp(): void
{
$this->calculate = m::mock('App\Calculate');
$this->math = new Math($this->calculate);
}
public function test_getArea_WhenCalledWithLength2_Return4()
{
$this->calculate->shouldReceive('areaOfSquare')
->andReturn(4)
->once();
$length = 2;
$response = $this->math->getArea($length);
$this->assertTrue(is_int($response));
$this->assertEquals(4, $response);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment