- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
php_sapi_name() === 'cli' or exit('Only CLI mode allowed');
getenv('API_HOST') or exit(<<<EOT
To run tests you should setup "API_HOST" environment variable.
Try follow in bash command line:
$ export API_HOST=<api_host>
cd path/to/tests
php direct_report_problem.php
EOT
);
defined('API_ENDPOINT') || define('API_ENDPOINT', getenv('API_HOST') . '/webservice/index.php');
$method = API_ENDPOINT . '?op=...';
$describe = function ($msg, $test) {
printf("\n\n[%s]\n\n%s\n\n", $msg, shell_exec($test()));
sleep(2);
};
$describe('Cannot upload empty report', function() use ($method) {
return 'curl'
. ' -F user_id=61'
. ' ' . $method;
});
$describe('Can upload only direct report note', function() use ($method) {
return 'curl'
. ' -F user_id=61'
. ' -F problem_note=NOTE'
. ' ' . $method;
});
$describe('Can upload only direct report sound', function() use ($method) {
return 'curl'
. ' -F user_id=61'
. ' -F [email protected]'
. ' ' . $method;
});
$describe('Can upload only direct report image', function() use ($method) {
return 'curl'
. ' -F user_id=61'
. ' -F [email protected]'
. ' ' . $method;
});
$describe('Can upload all data direct report note, image, sound', function() use ($method) {
return 'curl'
. ' -F user_id=61'
. ' -F problem_note=NOTE'
. ' -F [email protected]'
. ' -F [email protected]'
. ' ' . $method;
});
Да он ему не особо то и нужен. Мало кто юзает PHP из консольки.
Ну и это не оптпарсер. Это, имхо, что-то типа корявого юнит-теста для API: отправляем различные команды вебсервису и выводим их название и результат.
Какой пиздец... Если уж бежать - то на жабу\решетку.