Allow uploading images (#13)
Adds an optional field for the post image. Fixes #12 Co-authored-by: clfreville2 <clement.freville2@etu.uca.fr> Reviewed-on: https://codefirst.iut.uca.fr/git/clement.freville2/herbarium/pulls/13 Reviewed-by: Bastien OLLIER <bastien.ollier@noreply.codefirst.iut.uca.fr>
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Repository\PostRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
|
||||
class PostControllerTest extends WebTestCase
|
||||
{
|
||||
@@ -147,4 +148,24 @@ class PostControllerTest extends WebTestCase
|
||||
$comments = $this->repository->find($fixture->getId())->getComments();
|
||||
self::assertSame(1, $comments->count());
|
||||
}
|
||||
|
||||
public function testUploadImage()
|
||||
{
|
||||
$fixture = new Post();
|
||||
$fixture->setFoundDate(new \DateTimeImmutable('2024-01-01 00:00:00'));
|
||||
$fixture->setCommentary('Cool stuff');
|
||||
|
||||
$this->manager->persist($fixture);
|
||||
$this->manager->flush();
|
||||
|
||||
$file = new UploadedFile(__DIR__ . '/../image.png', 'image.png');
|
||||
|
||||
$this->client->request('GET', sprintf('%s%s/edit', $this->path, $fixture->getId()));
|
||||
|
||||
$this->client->submitForm('Update', [
|
||||
'post[imageFile]' => $file,
|
||||
]);
|
||||
|
||||
self::assertNotNull($this->repository->find($fixture->getId())->getImage());
|
||||
}
|
||||
}
|
||||
|
BIN
tests/image.png
Normal file
BIN
tests/image.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 67 B |
Reference in New Issue
Block a user