diff --git a/src/CoreBundle/Controller/Api/CreateCToolIntroAction.php b/src/CoreBundle/Controller/Api/CreateCToolIntroAction.php deleted file mode 100644 index 3f11b50c7c..0000000000 --- a/src/CoreBundle/Controller/Api/CreateCToolIntroAction.php +++ /dev/null @@ -1,22 +0,0 @@ -handleCreateRequest(new CToolIntro(), $repo, $request); - - return $repo->updateToolIntro($em, $result['introText']); - } -} diff --git a/src/CoreBundle/Controller/Api/UpdateCToolIntroAction.php b/src/CoreBundle/Controller/Api/UpdateCToolIntroAction.php deleted file mode 100644 index add1a7eac8..0000000000 --- a/src/CoreBundle/Controller/Api/UpdateCToolIntroAction.php +++ /dev/null @@ -1,31 +0,0 @@ -handleUpdateRequest($toolIntro, $repo, $request, $em); - - $result = json_decode($request->getContent(), true); - - var_dump($result); - - //$toolIntro = $repo->updateToolIntro($em, $result['introText']); - - return $toolIntro; - } -} diff --git a/src/CourseBundle/Entity/CToolIntro.php b/src/CourseBundle/Entity/CToolIntro.php index 7b7399e502..cc85165c9a 100644 --- a/src/CourseBundle/Entity/CToolIntro.php +++ b/src/CourseBundle/Entity/CToolIntro.php @@ -9,8 +9,6 @@ namespace Chamilo\CourseBundle\Entity; use ApiPlatform\Core\Annotation\ApiFilter; use ApiPlatform\Core\Annotation\ApiResource; use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter; -use Chamilo\CoreBundle\Controller\Api\CreateCToolIntroAction; -//use Chamilo\CoreBundle\Controller\Api\UpdateCToolIntroAction; use Chamilo\CoreBundle\Entity\AbstractResource; use Chamilo\CoreBundle\Entity\ResourceInterface; use Chamilo\CoreBundle\Entity\ResourceShowCourseResourcesInSessionInterface; @@ -33,7 +31,6 @@ use Symfony\Component\Validator\Constraints as Assert; 'security' => "is_granted('ROLE_USER')", ], 'post' => [ - 'controller' => CreateCToolIntroAction::class, 'security_post_denormalize' => "is_granted('CREATE', object)", ], ], @@ -42,8 +39,6 @@ use Symfony\Component\Validator\Constraints as Assert; 'security' => "is_granted('VIEW', object)", ], 'put' => [ - //'controller' => UpdateCToolIntroAction::class, - //'deserialize' => false, 'security' => "is_granted('EDIT', object)", ], 'delete' => [ diff --git a/tests/CourseBundle/Repository/CToolIntroRepositoryTest.php b/tests/CourseBundle/Repository/CToolIntroRepositoryTest.php index 5d4ef29812..16f1cb7982 100644 --- a/tests/CourseBundle/Repository/CToolIntroRepositoryTest.php +++ b/tests/CourseBundle/Repository/CToolIntroRepositoryTest.php @@ -6,6 +6,7 @@ declare(strict_types=1); namespace Chamilo\Tests\CourseBundle\Repository; +use Chamilo\CoreBundle\Entity\ResourceLink; use Chamilo\CourseBundle\Entity\CTool; use Chamilo\CourseBundle\Entity\CToolIntro; use Chamilo\CourseBundle\Repository\CToolIntroRepository; @@ -75,9 +76,7 @@ class CToolIntroRepositoryTest extends AbstractApiTest public function testCreateIntroApi(): void { $course = $this->createCourse('new'); - $token = $this->getUserToken(); - $resourceNodeId = $course->getResourceNode()->getId(); /** @var CTool $courseTool */ @@ -85,7 +84,7 @@ class CToolIntroRepositoryTest extends AbstractApiTest $iri = '/api/c_tools/'.$courseTool->getIid(); - $this->createClientWithCredentials($token)->request( + $response = $this->createClientWithCredentials($token)->request( 'POST', '/api/c_tool_intros', [ @@ -93,6 +92,12 @@ class CToolIntroRepositoryTest extends AbstractApiTest 'introText' => 'introduction here', 'courseTool' => $iri, 'parentResourceNodeId' => $resourceNodeId, + 'resourceLinkList' => [ + [ + 'cid' => $course->getId(), + 'visibility' => ResourceLink::VISIBILITY_PUBLISHED + ] + ] ], ] ); @@ -105,6 +110,17 @@ class CToolIntroRepositoryTest extends AbstractApiTest '@type' => 'CToolIntro', 'introText' => 'introduction here', ]); + + $repo = self::getContainer()->get(CToolIntroRepository::class); + $id = $response->toArray()['iid']; + + /** @var CToolIntro $toolIntro */ + $toolIntro = $repo->find($id); + $this->assertNotNull($toolIntro); + $this->assertNotNull($toolIntro->getResourceNode()); + $this->assertsame(1, $toolIntro->getResourceNode()->getResourceLinks()->count()); + + $this->assertSame(1, $repo->count([])); } public function testUpdateIntroApi(): void