Skip to content

Instantly share code, notes, and snippets.

@sameernyaupane
Last active May 24, 2021 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sameernyaupane/1ee74e84b5639cc808da18e7f507e101 to your computer and use it in GitHub Desktop.
Save sameernyaupane/1ee74e84b5639cc808da18e7f507e101 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()
{
$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);
}
}
@tim-andes
Copy link

Forked and fixed bug, added : void to setUp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment