Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
chamilo-lms/tests/CoreBundle/Controller/ResourceControllerTest.php

52 lines
1.5 KiB

<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\Tests\CoreBundle\Controller;
use Chamilo\CourseBundle\Entity\CDocument;
use Chamilo\CourseBundle\Repository\CDocumentRepository;
use Chamilo\Tests\ChamiloTestTrait;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class ResourceControllerTest extends WebTestCase
{
use ChamiloTestTrait;
public function testDownloadAction(): void
{
$client = static::createClient();
$admin = $this->getUser('admin');
$client->loginUser($admin);
$documentRepo = self::getContainer()->get(CDocumentRepository::class);
$course = $this->createCourse('Test');
$document = (new CDocument())
->setFiletype('file')
->setTitle('title 123')
->setTemplate(false)
->setReadonly(false)
->setParent($course)
->setCreator($admin)
->addCourseLink($course)
;
$documentRepo->create($document);
$documentRepo->addFileFromString($document, 'test', 'text/html', 'my file', true);
/** @var CDocument $document */
$document = $documentRepo->find($document->getIid());
$node = $document->getResourceNode();
$this->assertTrue($node->hasResourceFile());
$id = $node->getUuid()->toRfc4122();
$urlDownload = '/r/document/files/'.$id.'/download';
$client->request('GET', $urlDownload);
$this->assertResponseIsSuccessful();
}
}