I created a project with Laravel + Doctrine (instead of Eloquent) + Angular Routing . I decided to use php unit test for testing API (Controllers , Repositories) Actually I am geting an error while testing a simple method. Here is my code :
DoctorineRestaurantRepositoryTest.php:
class RestaurantTest extends TestCase
{
private $DoctrineRepository;
public function setUp() {
$this->DoctrineRepository = DoctrineRestaurantRepository::class;
}
/** @test */
public function validator()
{
$this->DoctrineRepository->setTestVariable(3);
$this->assertEquals($this->DoctrineRepository->getTestVariable(), 3);
}
.
.
.
}
my repository file: (DoctrineRestaurantRepository.php)
class DoctrineRestaurantRepository extends DoctrineBaseRepository
{
private $testVariable = 0;
/**
* @return int
*/
public function getTestVariable()
{
return $this->testVariable;
}
/**
* @param int $testVariable
*/
public function setTestVariable($testVariable)
{
$this->testVariable = $testVariable;
}
.
.
.
}
I ran test and it gave an error :
Call to a member function setTestVariable() on string
Any suggestion to fix it?