클래스 (FormFilters
)가 있는데이 클래스는 하나의 메서드 내에서 메서드를 호출합니다.이 경우 getProject
입니다.@dataProvider 또는 @depends를 사용할 수 있습니까?
public function test_getProject()
{
$formInterface = $this->createMock('Symfony\Component\Form\FormInterface');
$formInterface
->expects($this->at(0))
->method('isValid')
->willReturn(true); // come into conditional
$formInterface
->expects($this->at(1))
->method('get')
->with('name')
->will($this->returnSelf());
$formInterface
->expects($this->at(2))
->method('getData')
->will('data example');
$formFilters = new FormFilters();
$formFilters->getProject($formInterface); // my mock
}
지금까지 모든 권리 :
class FormFilters extends KernelTestCase
{
public function getProject($filters)
{
$this->filters = $filters;
$this->getWhere($this->filters);
}
public function getWhere()
{
if ($this->filters->isValid()) {
$this->sql = $this->filterName($this->filters->get('name')->getData());
}
}
public function filterName()
{
//....
}
}
이 getProject
방법의 테스트입니다. 나는이 (예)처럼, 주석 @dataProvider
또는 @depends
를 사용할 수 있습니다, 지금, getWhere
방법을 테스트 할, 내가 독립적으로 그것을 할 수 있지만 getProject
이 동일한 테스트가있는 경우 (getWhere
방법에 부름) :
/**
* @depends or/and @dataProvider test_getProject
*/
public function test_getWhere($dataToDepends)
{
// ... test ready !
}
가능합니까?