【发布时间】:2017-02-25 09:24:39
【问题描述】:
目前我的目录结构如下:
src
-App
--MyBundle
---Service
----DefaultService
tests
-AppMyBundle
--files
---data.csv
--Service
---DefaultServiceTest
我正在为文件阅读器编写测试,并添加了 data.csv 文件作为测试的演示文件。在我的测试中,我需要获取该data.csv 文件的路径。但我找不到任何获得它的方法。我曾尝试通过file_locator 服务访问它,例如:
$locator = $this->container->get('file_locator');
$path = $locator->locate('@AppMyBundle/Tests/files/data.csv');
和
$locator = $this->container->get('file_locator');
$path = $locator->locate('@AppMyBundle/files/data.
没有运气。
我的DefaultService 的命名空间是App\MyBundle\Service,而DefaultServiceTest 是App\MyBundle\Tests\Service
【问题讨论】:
标签: phpunit symfony file-location