phpunit test mockup
네.. 목업하는 법, 테스트하는 법 다 까먹었구요..😥 이게 맞는 지 모르겠다.. 틀린게 있다면 누군가 알려준다면 좋겠당..
[1] elasticsearch client의 search method 목업 처리방법
$elasticMock = $this->mock(Client::class);
$elasticMock->shouldReceive('search')
->once()
->andReturn(json_decode(file_get_contents(__DIR__.'\Mock\product.json'), true));
- product.json 파일
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 2,
"successful" : 2,
"skipped" : 0,
"failed" : 0
},
"hits": {
"total": {
"value":1,
"relation":"eq"
},
"max_score": null,
"hits": [{
"_index" : "product",
"_type" : "_doc",
"_id": "testadsfsdfad",
"_score" : null,
"_source": {
"store_id" : "누누",
"shop_name" : "눈뉴",
"shop_no" : 1,
"store_category" : "MALE_BAG"
}
}]
}
}
[2] 커스텀 클래스의 메서드 목업 처리방법
$customMock = $this->mock(CustomClass::class);
$customMock->shouldReceive('getCustomMethod')
->once()
->andReturn([
"test1" => '123456',
"test2" => ["asdfsdf"]
]);
Author And Source
이 문제에 관하여(phpunit test mockup), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@wjdgkrud/phpunit-test-mockup저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)