Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions docs/testing/asserting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ With a multi-part request, the assertions [`assertRaw`](#assertraw), [`assertRep
in the field containing the file.

### Example
To assert files you must use the `assertRaw` assertion in combination with `FormDataParser::parse($request)->files`,
To assert files you must use the `assertRaw` assertion,
see the example below:

<Tabs>
Expand All @@ -186,9 +186,9 @@ $this
'caption' => 'my caption',
'parse_mode' => ParseMode::HTML,
])
->assertRaw(function (Request $request) {
->assertRaw(function (RequestData $request) {
/** @var OutgoingResource $document */
$document = FormDataParser::parse($request)->files['document'];
$document = $request->file('document');

//check size
return $document->getSize() <= 123456;
Expand Down Expand Up @@ -216,10 +216,9 @@ $bot->onText('foo', function (Nutgram $bot) {
### OutgoingResource
This object is a wrapper from an outgoing resource and provide the following methods:

| Method | Type | Description |
|:-------------------|:------------|:-------------------------------------------------------------------|
| `getName()` | `?string` | Returns the file name. |
| `getType()` | `?string` | Returns the MIME content type. |
| `getSize()` | `int` | Returns the file size in bytes. |
| `getError()` | `int` | Returns 0 (There is no error) or 7 (Failed to create the resource) |
| `getTmpResource()` | `?resource` | Returns the resource. |
| Method | Type | Description |
|:--------------|:------------------|:--------------------------------|
| `getName()` | `?string` | Returns the file name. |
| `getMime()` | `string` | Returns the MIME content type. |
| `getSize()` | `?int` | Returns the file size in bytes. |
| `getStream()` | `StreamInterface` | Returns the resource. |
Loading