Error when call test
daitranthanhhoa opened this issue · comments
protected $translator;
protected $clean_data;
protected $virus_data;
protected $error_data;
protected $rules;
protected $messages;
public function setUp()
{
$this->translator = Mockery::mock(Translator::class);
$this->translator->shouldReceive('get')->with('validation.custom.file.clamav')->andReturn('error');
$this->translator->shouldReceive('get')->with('validation.attributes')->andReturn([]);
$this->translator->shouldReceive('trans');
$this->clean_data = [
'file' => "/var/www/html/gardenannex/storage/logs/clamav_test.txt"
];
$this->virus_data = [
'file' => "/var/www/html/gardenannex/storage/logs/clamav_test.txt"
];
$this->error_data = [
'file' => "/var/www/html/gardenannex/storage/logs/clamav_test.txt"
];
$this->messages = [];
$config = new Config();
$config->shouldReceive('get')->with('clamav.preferred_socket')->andReturn('unix_socket');
$config->shouldReceive('get')->with('clamav.unix_socket')->andReturn('/var/run/clamd.scan/clamd.sock');
$config->shouldReceive('get')->with('clamav.tcp_socket')->andReturn('tcp://127.0.0.1:3310');
$config->shouldReceive('get')->with('clamav.socket_read_timeout')->andReturn(30);
$config->shouldReceive('get')->with('clamav.skip_validation')->andReturn(false);
$application = Mockery::mock(Application::class, ['make' => $config]);
Facade::setFacadeApplication($application);
}
```
public function scan() {
$this->setUp();
$validator = new ClamavValidator(
$this->translator,
$this->clean_data,
['file' => 'clamav'],
$this->messages
);
$this->assertTrue($validator->passes())
}
}
Error:
`Fatal error: Uncaught Mockery\Exception\NoMatchingExpectationException: No matching handler found for Mockery_1_Illuminate_Config_Repository::get('app.debug', NULL). Either the method was unexpected or its arguments matched no expected argument list for this method in D:\EYEGLASSES\Source\gardenannex\vendor\mockery\mockery\library\Mockery\ExpectationDirector.php:92 Stack trace: #0 D:\EYEGLASSES\Source\gardenannex\vendor\mockery\mockery\library\Mockery\Loader\EvalLoader.php(34) : eval()'d code(868): Mockery\ExpectationDirector->call(Array) #1 D:\EYEGLASSES\Source\gardenannex\vendor\mockery\mockery\library\Mockery\Loader\EvalLoader.php(34) : eval()'d code(974): Mockery_1_Illuminate_Config_Repository->_mockery_handleMethodCall('get', Array) #2 D:\EYEGLASSES\Source\gardenannex\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php(283): Mockery_1_Illuminate_Config_Repository->get('app.debug', NULL) #3 D:\EYEGLASSES\Source\gardenannex\vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php(284): c in D:\EYEGLASSES\Source\gardenannex\vendor\mockery\mockery\library\Mockery\ExpectationDirector.php on line 92`
Not sure why you want to run it manually. As you can see here: https://travis-ci.org/sunspikes/clamav-validator this test (https://github.com/sunspikes/clamav-validator/blob/master/tests/ClamavValidatorTest.php) runs fine.
This could be something to do with your application setup and nothing to do with the library.
Btw the above error indicates app.debug
need to be mocked, you could add
$config->shouldReceive('get')->with('app.debug')->andReturn(false);
just before $application = Mockery::mock(Application::class, ['make' => $config]);