From f597bbe555e2240723ab36ef489d69653737d779 Mon Sep 17 00:00:00 2001 From: Massimiliano Arione Date: Sun, 13 Oct 2024 11:01:55 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=20FileInjector?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/index.md | 3 ++ src/File/FileInjector.php | 58 +++++++++++++++++++++++++++++++++++++++ src/Test/WebTestCase.php | 38 +++++-------------------- 3 files changed, 68 insertions(+), 31 deletions(-) create mode 100644 src/File/FileInjector.php diff --git a/docs/index.md b/docs/index.md index 4f6ca51..5270e32 100644 --- a/docs/index.md +++ b/docs/index.md @@ -135,6 +135,9 @@ services: In forms with more than a field of the same type, use `self::getImageFile('1')`, `self::getImageFile('2')`, etc. You can also use `self::getFile('0', $data, 'png', 'image/png')` and pass directly your file data. + 💡 ** Bonus** The above methods are shortcuts for the `Beelab\TestBundle\File\FileInjector` class, so you + can use them in your fixtures, too. Import the class and use `FileInjector::getFile()` etc. + * Form values shortcut If you need to retrieve the value of a form field, you can use `self::getFormValue('form_field')`. diff --git a/src/File/FileInjector.php b/src/File/FileInjector.php new file mode 100644 index 0000000..3ae9489 --- /dev/null +++ b/src/File/FileInjector.php @@ -0,0 +1,58 @@ +