Skip to content

Commit ba1781f

Browse files
committed
extra tests with data
1 parent e7ef9bb commit ba1781f

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
lines changed

templates/php/base/requests/file.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
$size = 0;
44
$mimeType = null;
55
$postedName = null;
6-
if(empty(${{ parameter.name | caseCamel }}->getPath())) {
6+
if(empty(${{ parameter.name | caseCamel }}->getPath() ?? null)) {
77
$size = strlen(${{ parameter.name | caseCamel }}->getData());
88
$mimeType = ${{ parameter.name | caseCamel }}->getMimeType();
99
$postedName = ${{ parameter.name | caseCamel }}->getFilename();

templates/php/src/InputFile.php.twig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class InputFile {
3333
{
3434
$instance = new InputFile();
3535
$instance->path = $path;
36+
$instance->data = null;
3637
$instance->mimeType = $mimeType;
3738
$instance->filename = $filename;
3839
return $instance;
@@ -41,6 +42,7 @@ class InputFile {
4142
public static function withData(string $data, ?string $mimeType = null, ?string $filename = null)
4243
{
4344
$instance = new InputFile();
45+
$instance->path = null;
4446
$instance->data = $data;
4547
$instance->mimeType = $mimeType;
4648
$instance->filename = $filename;

tests/PHP74Test.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class PHP74Test extends Base
1515
...Base::BAR_RESPONSES,
1616
...Base::GENERAL_RESPONSES,
1717
...Base::LARGE_FILE_RESPONSES,
18+
...Base::LARGE_FILE_RESPONSES,
19+
...Base::LARGE_FILE_RESPONSES,
1820
...Base::EXCEPTION_RESPONSES,
1921
];
2022
}

tests/PHP80Test.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class PHP80Test extends Base
1515
...Base::BAR_RESPONSES,
1616
...Base::GENERAL_RESPONSES,
1717
...Base::LARGE_FILE_RESPONSES,
18+
...Base::LARGE_FILE_RESPONSES,
19+
...Base::LARGE_FILE_RESPONSES,
1820
...Base::EXCEPTION_RESPONSES,
1921
];
2022
}

tests/languages/php/test.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@
6161
$response = $general->redirect();
6262
echo "{$response['result']}\n";
6363

64+
$data = file_get_contents(__DIR__ . '/../../resources/file.png');
65+
$response = $general->upload('string', 123, ['string in array'], InputFile::withData($data, 'image/png', 'file.png'));
66+
echo "{$response['result']}\n";
67+
68+
$data = file_get_contents(__DIR__ . '/../../resources/large_file.mp4');
69+
$response = $general->upload('string', 123, ['string in array'], InputFile::withData($data, 'video/mp4', 'large_file.mp4'));
70+
echo "{$response['result']}\n";
71+
6472
$response = $general->upload('string', 123, ['string in array'], InputFile::withPath(__DIR__ .'/../../resources/file.png'));
6573
echo "{$response['result']}\n";
6674

0 commit comments

Comments
 (0)