I'm a refactoring a symfony2 application with phpspec. But when i try to test it i keep getting the same error on the first step.
bin/phpspec run -v
Test/Bundle/TestBundle/Service/TestService
36 ! it is initializable
class TestRepository not found.
0 vendor/phpspec/prophecy/src/Prophecy/Doubler/LazyDouble.php:58
throw new Prophecy\Exception\Doubler\ClassNotFoundException("Class TestRepository"...)
1 vendor/phpspec/prophecy/src/Prophecy/Prophecy/ObjectProphecy.php:63
Prophecy\Doubler\LazyDouble->setParentClass("TestRepository")
I have used the correct namespace in front and added the let() to my spec.
use Test\Bundle\TestBundle\Service\TestService;
class TestServiceSpec extends ObjectBehavior
{
/**
* @param TestRepository $repository
*/
function let(
TestRepository $repository,
)
{
$this->beConstructedWith($repository, $validator, $eventDay, $log);
}
/**
*
*/
function it_is_initializable()
{
$this->shouldHaveType('Test\Bundle\TestBundle\Service\TestService');
}
And my service:
use Test\Bundle\TestBundle\Repository\TestRepository;
/**
* Test service class.
*/
class TestService
{
/**
* Repository
* @var \Test\Bundle\TestBundle\Repository\TestRepository
*/
protected $repository;
/**
* Constructor.
*
* @param TestRepository $repository Doctrine mongodb object mapper.
*/
public function __construct(TestRepository $repository)
{
$this->repository = $repository;
}
I have no clue what is wrong and cna't find any resources on the internet / stackoverflow. Thnx in advance for your help :)