forked from GNUsocial/gnu-social
[TESTS] Raise test coverage for Attachment controller to 100%
This commit is contained in:
parent
69ff8c2750
commit
b0f5352a53
@ -43,16 +43,16 @@ class AttachmentTest extends GNUsocialTestCase
|
|||||||
$this->assertSelectorTextContains('.stacktrace', 'ClientException');
|
$this->assertSelectorTextContains('.stacktrace', 'ClientException');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function testAttachment(string $suffix)
|
private function testAttachment(string $suffix = '')
|
||||||
{
|
{
|
||||||
$client = static::createClient();
|
$client = static::createClient();
|
||||||
$attachment = DB::findOneBy('attachment', ['filehash' => '5d8ee7ead51a28803b4ee5cb2306a0b90b6ba570f1e5bcc2209926f6ab08e7ea']);
|
$id = DB::findOneBy('attachment', ['filehash' => '5d8ee7ead51a28803b4ee5cb2306a0b90b6ba570f1e5bcc2209926f6ab08e7ea'])->getId();
|
||||||
$crawler = $client->request('GET', "/attachment/{$attachment->getId()}{$suffix}");
|
$crawler = $client->request('GET', "/attachment/{$id}{$suffix}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAttachmentShow()
|
public function testAttachmentShow()
|
||||||
{
|
{
|
||||||
$this->testAttachment('');
|
$this->testAttachment();
|
||||||
$this->assertResponseIsSuccessful();
|
$this->assertResponseIsSuccessful();
|
||||||
$this->assertSelectorTextContains('figure figcaption', '5d8ee7ead51a28803b4ee5cb2306a0b90b6ba570f1e5bcc2209926f6ab08e7ea');
|
$this->assertSelectorTextContains('figure figcaption', '5d8ee7ead51a28803b4ee5cb2306a0b90b6ba570f1e5bcc2209926f6ab08e7ea');
|
||||||
}
|
}
|
||||||
@ -63,6 +63,16 @@ class AttachmentTest extends GNUsocialTestCase
|
|||||||
$this->assertResponseIsSuccessful();
|
$this->assertResponseIsSuccessful();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testAttachmentViewNotStored()
|
||||||
|
{
|
||||||
|
$client = static::createClient();
|
||||||
|
$last_attachment = DB::findBy('attachment', [], orderBy: ['id' => 'DESC'], limit: 1)[0];
|
||||||
|
$id = $last_attachment->getId() + 1;
|
||||||
|
$crawler = $client->request('GET', "/attachment/{$id}/view");
|
||||||
|
$this->assertResponseStatusCodeSame(500); // TODO (exception page) 404
|
||||||
|
$this->assertSelectorTextContains('.stacktrace', 'ClientException');
|
||||||
|
}
|
||||||
|
|
||||||
public function testAttachmentDownload()
|
public function testAttachmentDownload()
|
||||||
{
|
{
|
||||||
$this->testAttachment('/download');
|
$this->testAttachment('/download');
|
||||||
|
Loading…
Reference in New Issue
Block a user