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/Repository/SettingsCurrentRepositoryTe...

68 lines
2.2 KiB

<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\Tests\CoreBundle\Repository;
use Chamilo\CoreBundle\Entity\SettingsCurrent;
4 years ago
use Chamilo\CoreBundle\Entity\SettingsOptions;
use Chamilo\CoreBundle\Repository\SettingsCurrentRepository;
use Chamilo\Tests\AbstractApiTest;
use Chamilo\Tests\ChamiloTestTrait;
class SettingsCurrentRepositoryTest extends AbstractApiTest
{
use ChamiloTestTrait;
public function testCreate(): void
{
$em = $this->getEntityManager();
$repo = self::getContainer()->get(SettingsCurrentRepository::class);
$count = $repo->count([]);
4 years ago
$setting = (new SettingsCurrent())
->setTitle('test')
->setVariable('test')
->setUrl($this->getAccessUrl())
->setCategory('cat')
4 years ago
->setAccessUrlLocked(1)
->setAccessUrlChangeable(1)
4 years ago
->setSubkey('sub')
->setType('type')
->setComment('comment')
->setSubkeytext('setSubkeytext')
4 years ago
->setScope('scope')
;
4 years ago
$this->assertHasNoEntityViolations($setting);
$em->persist($setting);
$option = (new SettingsOptions())
->setValue('value')
->setDisplayText('option1')
->setVariable('variable')
;
$this->assertHasNoEntityViolations($option);
4 years ago
$em->persist($option);
$em->flush();
4 years ago
$this->assertNotNull($setting->getId());
$this->assertSame('test', $setting->getTitle());
$this->assertSame('sub', $setting->getSubkey());
$this->assertSame('type', $setting->getType());
$this->assertSame('comment', $setting->getComment());
$this->assertSame('scope', $setting->getScope());
$this->assertSame(1, $setting->getAccessUrlChangeable());
$this->assertSame(1, $setting->getAccessUrlLocked());
$this->assertNotNull($option->getId());
$this->assertSame('variable', $option->getVariable());
$this->assertSame('value', $option->getValue());
$this->assertSame('option1', $option->getDisplayText());
// By default, there's a root branch.
$this->assertSame($count + 1, $repo->count([]));
}
}