В своем тестовом классе я поместил этот код:
Код: Выделить всё
public function testExportCsv()
{
$mockObject = $this->getMockBuilder('\Client')
->setConstructorArgs(array("0"))
->getMock();
$res = $this->searchDocApiDocumentsStub();
$mockObject->method('searchDocuments')
->willReturn($res);
}
public function searchDocApiDocumentsStub()
{
$res = array();
$yml = Yaml::parse(file_get_contents("../src/ExportCSVBundle/Resources/config/generic.yml"));
$typeDoc = "FAC";
$metas[$typeDoc] = $yml["ETT"][strtoupper($typeDoc)];
foreach ($this->documents as $document) {
if ($document["type"] == "DocumentsAPI\\Model\\" . str_replace('$eq ', '', $typeDoc)) {
foreach ($metas[$typeDoc] as $field) {
$docres[] = $document["metas"][$field];
}
$res = array_merge($res, $docres);
}
}
return $res;
}
Тогда мне придется использовать этот объект.
Код: Выделить всё
class Export {
public function __construct(Client $docApiClient)
{
$this->docApiClient = $docApiClient;
}
$docs = $this->docApiClient->searchDocuments($client, $query, null, false, false, $metasToExport);
Код: Выделить всё
$export = new \ExportLibraryBundle\ExportLibrary\Export(//What Do I put ??);
Подробнее здесь: https://stackoverflow.com/questions/439 ... test-class