192 lines
8.2 KiB
PHP
192 lines
8.2 KiB
PHP
<?php
|
||
|
||
class FooCest
|
||
{
|
||
public function tryPostJsonToFilter(FooTester $I)
|
||
{
|
||
$I->haveHttpHeader('User-Agent', 'FEIP Tester');
|
||
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||
$I->sendPOST(
|
||
'/index.php',
|
||
[
|
||
'{
|
||
"foo": "123",
|
||
"bar": "asd",
|
||
"baz": "79502885623"
|
||
}'
|
||
]
|
||
);
|
||
$I->seeResponseContains('{"response":{"foo":123,"bar":"asd","baz":"79502885623"},"errors":[]}');
|
||
}
|
||
|
||
public function tryPostJsonToFilterButFooIsEmpty(FooTester $I)
|
||
{
|
||
$I->haveHttpHeader('User-Agent', 'FEIP Tester');
|
||
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||
$I->sendPOST(
|
||
'/index.php',
|
||
[
|
||
'{
|
||
"foo": "",
|
||
"bar": "asd",
|
||
"baz": "79502885623"
|
||
}'
|
||
]
|
||
);
|
||
$I->seeResponseContains('{"response":{"foo":0,"bar":"asd","baz":"79502885623"},"errors":[{"type":100,"target":"foo","value":"\u041d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440"}]}');
|
||
}
|
||
|
||
public function tryPostJsonToFilterButFooHasWrongValue(FooTester $I)
|
||
{
|
||
$I->haveHttpHeader('User-Agent', 'FEIP Tester');
|
||
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||
$I->sendPOST(
|
||
'/index.php',
|
||
[
|
||
'{
|
||
"foo": "123абв",
|
||
"bar": "asd",
|
||
"baz": "79502885623"
|
||
}'
|
||
]
|
||
);
|
||
$I->seeResponseContains('{"response":{"foo":123,"bar":"asd","baz":"79502885623"},"errors":[{"type":200,"target":"foo","value":"\u041d\u0435\u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430"}]}');
|
||
}
|
||
|
||
public function tryPostJsonToFilterButFooWithoutValue(FooTester $I)
|
||
{
|
||
$I->haveHttpHeader('User-Agent', 'FEIP Tester');
|
||
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||
$I->sendPOST(
|
||
'/index.php',
|
||
[
|
||
'{
|
||
"bar": "asd",
|
||
"baz": "79502885623"
|
||
}'
|
||
]
|
||
);
|
||
$I->seeResponseContains('{"response":{"foo":0,"bar":"asd","baz":"79502885623"},"errors":[{"type":100,"target":"foo","value":"\u041d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440"}]}');
|
||
}
|
||
|
||
public function tryPostJsonToFilterButBarIsEmpty(FooTester $I)
|
||
{
|
||
$I->haveHttpHeader('User-Agent', 'FEIP Tester');
|
||
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||
$I->sendPOST(
|
||
'/index.php',
|
||
[
|
||
'{
|
||
"foo": "123",
|
||
"bar": "",
|
||
"baz": "79502885623"
|
||
}'
|
||
]
|
||
);
|
||
$I->seeResponseContains('{"response":{"foo":123,"bar":"","baz":"79502885623"},"errors":[{"type":100,"target":"bar","value":"\u041d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440"}]}');
|
||
}
|
||
|
||
public function tryPostJsonToFilterButBarWithoutValue(FooTester $I)
|
||
{
|
||
$I->haveHttpHeader('User-Agent', 'FEIP Tester');
|
||
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||
$I->sendPOST(
|
||
'/index.php',
|
||
[
|
||
'{
|
||
"foo": "123",
|
||
"baz": "79502885623"
|
||
}'
|
||
]
|
||
);
|
||
$I->seeResponseContains('{"response":{"foo":123,"bar":"","baz":"79502885623"},"errors":[{"type":100,"target":"bar","value":"\u041d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440"}]}');
|
||
}
|
||
|
||
public function tryPostJsonToFilterButBazIsEmpty(FooTester $I)
|
||
{
|
||
$I->haveHttpHeader('User-Agent', 'FEIP Tester');
|
||
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||
$I->sendPOST(
|
||
'/index.php',
|
||
[
|
||
'{
|
||
"foo": "123",
|
||
"bar": "asd",
|
||
"baz": ""
|
||
}'
|
||
]
|
||
);
|
||
$I->seeResponseContains('{"response":{"foo":123,"bar":"asd","baz":""},"errors":[{"type":100,"target":"baz","value":"\u041d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440"}]}');
|
||
}
|
||
|
||
public function tryPostJsonToFilterButBazHasWrongValue(FooTester $I)
|
||
{
|
||
$I->haveHttpHeader('User-Agent', 'FEIP Tester');
|
||
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||
$I->sendPOST(
|
||
'/index.php',
|
||
[
|
||
'{
|
||
"foo": "123",
|
||
"bar": "asd",
|
||
"baz": "8 (950) 288-56-23"
|
||
}'
|
||
]
|
||
);
|
||
$I->seeResponseContains('{"response":{"foo":123,"bar":"asd","baz":"79502885623"},"errors":[{"type":200,"target":"baz","value":"\u041d\u0435\u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430"}]}');
|
||
}
|
||
|
||
public function tryPostJsonToFilterButBazHasTooShortValue(FooTester $I)
|
||
{
|
||
$I->haveHttpHeader('User-Agent', 'FEIP Tester');
|
||
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||
$I->sendPOST(
|
||
'/index.php',
|
||
[
|
||
'{
|
||
"foo": "123",
|
||
"bar": "asd",
|
||
"baz": "260557"
|
||
}'
|
||
]
|
||
);
|
||
$I->seeResponseContains('{"response":{"foo":123,"bar":"asd","baz":"760557"},"errors":[{"type":200,"target":"baz","value":"\u041d\u0435\u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430"}]}');
|
||
}
|
||
|
||
public function tryPostJsonToFilterButBazWithoutValue(FooTester $I)
|
||
{
|
||
$I->haveHttpHeader('User-Agent', 'FEIP Tester');
|
||
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||
$I->sendPOST(
|
||
'/index.php',
|
||
[
|
||
'{
|
||
"foo": "123",
|
||
"bar": "asd"
|
||
}'
|
||
]
|
||
);
|
||
$I->seeResponseContains('{"response":{"foo":123,"bar":"asd","baz":""},"errors":[{"type":100,"target":"baz","value":"\u041d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440"}]}');
|
||
}
|
||
|
||
public function tryPostJsonToFilterButBarIsArray(FooTester $I)
|
||
{
|
||
$I->haveHttpHeader('User-Agent', 'FEIP Tester');
|
||
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||
$I->sendPOST(
|
||
'/index.php',
|
||
[
|
||
'{
|
||
"foo": "123",
|
||
"bar": {
|
||
"bar_foo": "100",
|
||
"bar_bar": "sad"
|
||
},
|
||
"baz": "79502885623"
|
||
}'
|
||
]
|
||
);
|
||
$I->seeResponseContains('{"response":{"foo":123,"bar":"","baz":"79502885623"},"errors":[{"type":200,"target":"bar","value":"\u041d\u0435\u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430"}]}');
|
||
}
|
||
}
|