Merge remote-tracking branch 'origin/master'

ofaj2
Angel Fernando Quiroz Campos 10 months ago
commit c5d06a4ce2
  1. 6
      assets/vue/App.vue
  2. 10
      public/main/inc/lib/tracking.lib.php
  3. 10
      src/CoreBundle/Controller/Api/BaseResourceFileAction.php
  4. 2
      tests/CoreBundle/Controller/AccountControllerTest.php
  5. 12
      tests/CoreBundle/Repository/Node/UserRepositoryTest.php
  6. 4
      tests/CoreBundle/Repository/PageRepositoryTest.php
  7. 4
      tests/README.md

@ -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);
}
}

@ -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;

@ -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;

@ -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');

@ -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

@ -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);

@ -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:

Loading…
Cancel
Save