diff --git a/assets/vue/App.vue b/assets/vue/App.vue index e79d30744e..d7185423f1 100644 --- a/assets/vue/App.vue +++ b/assets/vue/App.vue @@ -138,10 +138,10 @@ onUpdated(() => { const flashes = JSON.parse(app.dataset.flashes) for (const key in flashes) { - let capitalKey = capitalize(key) + const notificationType = key === 'danger' ? 'Error' : capitalize(key); - for (const flashText in flashes[key]) { - notification[`show${capitalKey}Notification`](flashes[key][flashText]) + for (const flashText of flashes[key]) { + notification[`show${notificationType}Notification`](flashText); } } diff --git a/public/main/inc/lib/tracking.lib.php b/public/main/inc/lib/tracking.lib.php index 5940c59abc..82579cf3b4 100644 --- a/public/main/inc/lib/tracking.lib.php +++ b/public/main/inc/lib/tracking.lib.php @@ -2488,15 +2488,7 @@ class Tracking } else { if (!empty($row['lp_id'])) { $tbl_lp = Database::get_course_table(TABLE_LP_MAIN); - $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); - $sql = "SELECT lp.title - FROM $tbl_lp as lp, $tbl_course as c - WHERE - c.code = '$course_code' AND - lp.iid = ".$row['lp_id']." AND - lp.c_id = c.id - LIMIT 1; - "; + $sql = "SELECT title FROM $tbl_lp WHERE iid = ".(int) $row['lp_id']; $result = Database::query($sql); $row_lp = Database::fetch_row($result); $lp_name = null; diff --git a/src/CoreBundle/Controller/Api/BaseResourceFileAction.php b/src/CoreBundle/Controller/Api/BaseResourceFileAction.php index 6577c4cb03..fcd8a13df3 100644 --- a/src/CoreBundle/Controller/Api/BaseResourceFileAction.php +++ b/src/CoreBundle/Controller/Api/BaseResourceFileAction.php @@ -185,7 +185,13 @@ class BaseResourceFileAction /** * Function loaded when creating a resource using the api, then the ResourceListener is executed. */ - protected function handleCreateFileRequest(AbstractResource $resource, ResourceRepository $resourceRepository, Request $request, EntityManager $em, string $fileExistsOption = ''): array + protected function handleCreateFileRequest( + AbstractResource $resource, + ResourceRepository $resourceRepository, + Request $request, + EntityManager $em, + string $fileExistsOption = '' + ): array { $contentData = $request->getContent(); @@ -316,7 +322,7 @@ class BaseResourceFileAction } if (!$fileParsed) { - throw new InvalidArgumentException('filetype was set to "file" but not upload file found'); + throw new InvalidArgumentException('filetype was set to "file" but no upload file found'); } break; diff --git a/tests/CoreBundle/Controller/AccountControllerTest.php b/tests/CoreBundle/Controller/AccountControllerTest.php index cf7c0c29ee..f5a9bc397d 100644 --- a/tests/CoreBundle/Controller/AccountControllerTest.php +++ b/tests/CoreBundle/Controller/AccountControllerTest.php @@ -26,7 +26,7 @@ class AccountControllerTest extends WebTestCase $client->submitForm('Update profile', [ 'profile[firstname]' => 'admin firstname', - 'profile[email]' => 'test@test.com', + 'profile[email]' => 'test@example.com', // 'profile[mail_notify_invitation]' => 1, ]); $this->assertResponseRedirects('/account/home'); diff --git a/tests/CoreBundle/Repository/Node/UserRepositoryTest.php b/tests/CoreBundle/Repository/Node/UserRepositoryTest.php index 4aec368854..71bd2c8bbf 100644 --- a/tests/CoreBundle/Repository/Node/UserRepositoryTest.php +++ b/tests/CoreBundle/Repository/Node/UserRepositoryTest.php @@ -13,6 +13,8 @@ use Chamilo\Tests\AbstractApiTest; use Chamilo\Tests\ChamiloTestTrait; use DateTime; use Symfony\Component\Security\Core\Exception\UserNotFoundException; +use Chamilo\CoreBundle\Entity\UserCourseCategory; +use Chamilo\CoreBundle\Framework\Container; class UserRepositoryTest extends AbstractApiTest { @@ -53,6 +55,11 @@ class UserRepositoryTest extends AbstractApiTest public function testDeleteUser(): void { + // Force loading the legacy container to avoid issue in the user deletion process + // using api_get_local_time() which uses api_get_setting() which uses Container::$container + Container::$container = self::getContainer(); + + /* @var UserRepository $userRepo */ $userRepo = self::getContainer()->get(UserRepository::class); $student = $this->createUser('student'); $defaultCount = $userRepo->count([]); @@ -196,6 +203,10 @@ class UserRepositoryTest extends AbstractApiTest public function testCreateUserSkipResourceNode(): void { + // Force loading the legacy container to avoid issue in the user deletion process + // using api_get_local_time() which uses api_get_setting() which uses Container::$container + Container::$container = self::getContainer(); + $em = $this->getEntityManager(); $userRepo = self::getContainer()->get(UserRepository::class); @@ -352,6 +363,7 @@ class UserRepositoryTest extends AbstractApiTest $user = $this->createUser('user', 'user'); $friend = $this->createUser('friend', 'friend'); + /* @var UserRepository $userRepo */ $userRepo = self::getContainer()->get(UserRepository::class); // user -> friend diff --git a/tests/CoreBundle/Repository/PageRepositoryTest.php b/tests/CoreBundle/Repository/PageRepositoryTest.php index 96e15c835a..1d64e37520 100644 --- a/tests/CoreBundle/Repository/PageRepositoryTest.php +++ b/tests/CoreBundle/Repository/PageRepositoryTest.php @@ -303,7 +303,9 @@ class PageRepositoryTest extends AbstractApiTest { $this->testDeleteAll(); + /** @var PageCategoryRepository $pageCategoryRepo */ $pageCategoryRepo = self::getContainer()->get(PageCategoryRepository::class); + /** @var PageRepository $pageRepo */ $pageRepo = self::getContainer()->get(PageRepository::class); /** @var CreateDefaultPages $createDefaultPages */ @@ -314,7 +316,7 @@ class PageRepositoryTest extends AbstractApiTest $result = $createDefaultPages->createDefaultPages($admin, $this->getAccessUrl(), 'en_US'); $this->assertTrue($result); $this->assertSame(2, $pageRepo->count([])); - $this->assertSame(2, $pageCategoryRepo->count([])); + $this->assertSame(4, $pageCategoryRepo->count([])); $result = $createDefaultPages->createDefaultPages($admin, $this->getAccessUrl(), 'en_US'); $this->assertFalse($result); diff --git a/tests/README.md b/tests/README.md index 7e7a714713..0ad404fe0c 100755 --- a/tests/README.md +++ b/tests/README.md @@ -46,13 +46,13 @@ php bin/console --env=test doctrine:fixtures:load --no-interaction If there are DB changes you can migrate your test installation with: -`php bin/console --env=test doctrine:schema:update --force` +`php bin/console --env=test doctrine:schema:update --force --complete` Those commands will install Chamilo in the chamilo_test database. In order to delete the test database and restart the process use: -`php bin/console --env=test doctrine:database:drop --force` +`php bin/console --env=test doctrine:database:drop --force --complete` ### Use Execute the tests with: