나는 다음과 같은 시험이 있습니다는 laravel의 단위 테스트와 Hamcrest의 hasKeyValuePair를 사용
public function testTestNameRequired(){
Validator::shouldReceive("make")->once()
->with(array(1,2,3), hasKeyValuePair("name",array("required")))
->andReturn(m::mock(["passes"=>true]));
$r = $this->vendorRepo->test(array(1,2,3));
assertThat($r,is(TRUE));
}
나는이 테스트를 실행할 때, 나는 다음과 같은 오류 얻을 :
1) VendorRepoTest::testTestNameRequired
Mockery\Exception\NoMatchingExpectationException: No matching handler found for Illuminate\Validation\Factory::make(Array, Array). Either the method was unexpected or its arguments matched no expected argument list for this method
Hamcrest 분명히 설치를 테스트 아무튼 때문에 hasKeyValuePair()
이 무엇인지 모르는 것에 대해 우는 소리. 그러나 그것이 그것이해야한다고 생각하는 것을하지 않는다고 생각합니다.
public function _testTestFieldRequired($field){
Validator::shouldReceive("make")->once()
->with(array(1,2,3), anything()) //hasKeyValuePair($field,array("required")))
->andReturn(m::mock(["passes"=>true]));
$r = $this->vendorRepo->test(array(1,2,3));
assertThat($r,is(TRUE));
}
내가 같은 오류가 발생합니다 : 나는이 같은 Hamcrest의 anything()
방법을 사용하여 다시 썼다. 그러나 Mockery::any()
작품을 사용 : 내가 조롱가 없거나 Hamcrest가 제대로 설치되었는지 생각하고
public function _testTestFieldRequired($field){
Validator::shouldReceive("make")->once()
->with(array(1,2,3), Mockery::any()) //hasKeyValuePair($field,array("required")))
->andReturn(m::mock(["passes"=>true]));
$r = $this->vendorRepo->test(array(1,2,3));
assertThat($r,is(TRUE));
}
. 그들은 함께 잘 놀고 있지 않습니다. 무슨 일이 일어나고 있는지
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"require": {
"laravel/framework": "4.0.*",
"way/generators": "dev-master",
"zurb/foundation": "v4.3.1",
"intervention/image": "dev-master",
"intervention/helper": "dev-master"
},
"require-dev": {
"mockery/mockery": "[email protected]",
"cordoval/hamcrest-php": "[email protected]",
"way/laravel-test-helpers": "dev-master",
"loic-sharma/profiler": "dev-master"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php",
"app/OfficePilot"
],
"files": [
"vendor/cordoval/hamcrest-php/hamcrest/Hamcrest.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "dev"
}
어떤 생각 : 여기 내 composer.json은?