私はphpspecでsymfony2アプリケーションをリファクタリングしています。しかし、テストしようとすると、最初のステップで同じエラーが発生し続けます。
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")
前に正しい名前空間を使用し、仕様に let() を追加しました。
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');
}
そして私のサービス:
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;
}
何が悪いのかわからず、インターネット/スタックオーバーフローでリソースが見つかりません。あなたの助けのために前もってThnx :)