From 5cb144a94525cc63c65bc4fe79b51a191e712302 Mon Sep 17 00:00:00 2001 From: Julio Date: Sun, 3 Oct 2021 14:15:32 +0200 Subject: [PATCH] Migrations: Fix ctoolintro --- .../Migrations/Schema/V200/Version20191101132000.php | 4 +++- src/CourseBundle/Entity/CToolIntro.php | 2 +- tests/CourseBundle/Repository/CToolIntroRepositoryTest.php | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20191101132000.php b/src/CoreBundle/Migrations/Schema/V200/Version20191101132000.php index fcccb8aa15..a748c16804 100644 --- a/src/CoreBundle/Migrations/Schema/V200/Version20191101132000.php +++ b/src/CoreBundle/Migrations/Schema/V200/Version20191101132000.php @@ -176,10 +176,12 @@ class Version20191101132000 extends AbstractMigrationChamilo $this->addSql('DROP INDEX course ON c_tool_intro;'); } + $table = $schema->getTable('c_tool_intro'); + $this->addSql("DELETE FROM c_tool_intro WHERE id = '0' "); // Migrate only course intro. - $this->addSql("DELETE FROM c_tool_intro WHERE id <> 'course_homepage' "); + $this->addSql("DELETE FROM c_tool_intro WHERE id <> 'course_homepage' "); $this->addSql('ALTER TABLE c_tool_intro CHANGE id id VARCHAR(255) DEFAULT NULL'); diff --git a/src/CourseBundle/Entity/CToolIntro.php b/src/CourseBundle/Entity/CToolIntro.php index a231da24c4..b018e7d2e3 100644 --- a/src/CourseBundle/Entity/CToolIntro.php +++ b/src/CourseBundle/Entity/CToolIntro.php @@ -125,7 +125,7 @@ class CToolIntro extends AbstractResource implements ResourceInterface, Resource public function getResourceName(): string { - return substr(strip_tags($this->getIntroText()), 0, 10); + return $this->getCourseTool()->getName(); } public function setResourceName(string $name): self diff --git a/tests/CourseBundle/Repository/CToolIntroRepositoryTest.php b/tests/CourseBundle/Repository/CToolIntroRepositoryTest.php index ac90695736..3cc57fd3df 100644 --- a/tests/CourseBundle/Repository/CToolIntroRepositoryTest.php +++ b/tests/CourseBundle/Repository/CToolIntroRepositoryTest.php @@ -44,6 +44,9 @@ class CToolIntroRepositoryTest extends AbstractApiTest $em->flush(); $this->assertNotEmpty($intro->getIntroText()); + $this->assertNotNull($intro->getIid()); + $this->assertNotEmpty($intro->getResourceName()); + $this->assertSame(1, $repo->count([])); $repo->delete($intro); $this->assertSame(0, $repo->count([]));