Tests: Add phpunit tests, fix tests

pull/3965/head
Julio 4 years ago
parent 13cf63223e
commit 96483cf4cb
  1. 16
      .github/workflows/phpunit.yml
  2. 3
      src/CoreBundle/Settings/SettingsManager.php
  3. 21
      tests/CoreBundle/Controller/Admin/SettingsControllerTest.php

@ -58,9 +58,23 @@ jobs:
yarn set version 2.4.2
yarn --version
- name: Get yarn cache directory
id: yarn-cache
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- name: Cache yarn dependencies
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn-
- name: Install JS dependencies
run: |
sudo chmod -R 777 var public
yarn install
yarn run encore production
- name: Check PHP settings
run: |

@ -101,6 +101,9 @@ class SettingsManager implements SettingsManagerInterface
}
}
/**
* @return array|AbstractSettingsSchema[]
*/
public function getSchemas(): array
{
return $this->schemaRegistry->all();

@ -6,6 +6,7 @@ declare(strict_types=1);
namespace Chamilo\Tests\CoreBundle\Controller\Admin;
use Chamilo\CoreBundle\Settings\SettingsManager;
use Chamilo\Tests\ChamiloTestTrait;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@ -72,4 +73,24 @@ class SettingsControllerTest extends WebTestCase
$this->assertResponseIsSuccessful();
$this->assertStringContainsString('Chamilo modified 123', $client->getResponse()->getContent());
}
public function testListSettings(): void
{
$client = static::createClient();
$settingsManager = $this->getContainer()->get(SettingsManager::class);
// retrieve the admin
$admin = $this->getUser('admin');
// simulate $testUser being logged in
$client->loginUser($admin);
$schemas = $settingsManager->getSchemas();
foreach ($schemas as $name => $schema) {
$category = $settingsManager->convertServiceToNameSpace($name);
$client->request('GET', '/admin/settings/'.$category);
$this->assertResponseIsSuccessful();
}
}
}

Loading…
Cancel
Save