Hoi iedereen,

ik moet nu een unit test schrijven in laravel 4 en dit is de 1e keer dat ik dat moet doen.
na een paar dagen stoeien ben ik tot dit gekomen alleen krijg ik nu het idee dat er iets niet goed gaat.
iemand suggesties of tips?

BVD. Ralph

<?php use Motherbase\Engine\Pinboard\PinHandler;

class PinHandlerTest extends TestCase
{
private $pinRepositoryMock;

public function tearDown()
{
Mockery::close();
}

public function setUp()
{
parent::setUp();

$this->pinRepositoryMock = Mockery::mock('\Motherbase\Engine\Pinboard\PinRepositoryInterface');
App::instance('\Motherbase\Engine\Pinboard\PinRepositoryInterface', $this->pinRepositoryMock);

$this->pinHandler = new PinHandler($this->pinRepositoryMock);
}

public function testGetPin()
{
$pinMock = Mockery::Mock('\Motherbase\Engine\Pinboard\Pin');

// test variabelen
$profile_id = 1;
$pin_id = 1;
$image_id = 1;

$this->pinRepositoryMock
->shouldReceive('readPin')
->once()
->with( array( 'profile_id' => $profile_id,
'pin_id '=> $pin_id )
->andReturn('test');

$pinMock ->shouldReceive('getAttribute')
->with('created_at','2014-10-10 15:00:00')
->once();

$pinMock ->shouldReceive('setAttribute')
->with('date','10 OCT')
->once();

$pinMock ->shouldReceive('getAttribute')
->with('image_id','1')
->once();


\Image ::shouldReceive('getUrlById')
->once()
->andReturn('/');

$pinMock ->shouldReceive('setAttribute')
->with('image','/')
->once();

\Profile ::shouldReceive('getMenuProfileById')
->with($profile_id);
->once()
->andReturn(array());

$pin = $this->pinHandler->getPin($profile_id, $pin_id);

$this->assertEquals('test', 'test');
}
}

Reageren