Updated unit tests

This commit is contained in:
Matias Griese 2020-12-04 20:01:28 +02:00
parent 7c0ba80530
commit f25ea8f056
8 changed files with 732 additions and 1630 deletions

View File

@ -1,4 +1,5 @@
actor: Tester
bootstrap: _bootstrap.php
paths:
tests: tests
log: tests/_output
@ -6,7 +7,6 @@ paths:
support: tests/_support
envs: tests/_envs
settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
extensions:

View File

@ -61,12 +61,13 @@
"symfony/http-client": "^4.4"
},
"require-dev": {
"codeception/codeception": "^2.5",
"codeception/codeception": "^4.1",
"phpstan/phpstan": "^0.11",
"phpstan/phpstan-deprecation-rules": "^0.11",
"phpunit/php-code-coverage": "~6.1",
"phpunit/php-code-coverage": "~9.2",
"fzaninotto/faker": "^1.9",
"victorjonsson/markdowndocs": "dev-master"
"victorjonsson/markdowndocs": "dev-master",
"codeception/module-asserts": "^1.3"
},
"suggest": {
"ext-mbstring": "Recommended for better performance",

2253
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -40,16 +40,16 @@ class AssetsTest extends \Codeception\TestCase\Test
$item = reset($array);
$actual = json_encode($item);
$expected = '
{
{
"type":"css",
"elements":{
"elements":{
"asset":"\/test.css",
"asset_type":"css",
"order":0,
"group":"head",
"position":"pipeline",
"priority":10,
"attributes":{
"attributes":{
"type":"text\/css",
"rel":"stylesheet"
},
@ -69,17 +69,17 @@ class AssetsTest extends \Codeception\TestCase\Test
$item = reset($array);
$actual = json_encode($item);
$expected = '
{
{
"type":"js",
"elements":{
"elements":{
"asset":"\/test.js",
"asset_type":"js",
"order":0,
"group":"head",
"position":"pipeline",
"priority":10,
"attributes":[
"attributes":[
],
"modified":false,
"query":""
@ -98,16 +98,16 @@ class AssetsTest extends \Codeception\TestCase\Test
$item = reset($array);
$actual = json_encode($item);
$expected = '
{
{
"type":"css",
"elements":{
"elements":{
"asset":"\/test.css",
"asset_type":"css",
"order":0,
"group":"head",
"position":"pipeline",
"priority":10,
"attributes":{
"attributes":{
"type":"text\/css",
"rel":"stylesheet"
},
@ -128,16 +128,16 @@ class AssetsTest extends \Codeception\TestCase\Test
$item = reset($array);
$actual = json_encode($item);
$expected = '
{
{
"type":"css",
"elements":{
"elements":{
"asset":"http:\/\/www.somesite.com\/test.css",
"asset_type":"css",
"order":0,
"group":"head",
"position":"pipeline",
"priority":10,
"attributes":{
"attributes":{
"type":"text\/css",
"rel":"stylesheet"
},
@ -163,9 +163,9 @@ class AssetsTest extends \Codeception\TestCase\Test
$item = reset($array);
$actual = json_encode($item);
$expected = '
{
{
"type":"js",
"elements":{
"elements":{
"asset":"\/test.js",
"asset_type":"js",
"order":0,
@ -303,19 +303,19 @@ class AssetsTest extends \Codeception\TestCase\Test
$this->assets->setJsPipeline(true);
$this->assets->addJs('/system/assets/jquery/jquery-3.x.min.js');
$js = $this->assets->js('head', ['loading' => 'inline']);
$this->assertContains('"jquery",[],function()', $js);
$this->assertStringContainsString('"jquery",[],function()', $js);
$this->assets->reset();
$this->assets->setCssPipeline(true);
$this->assets->addCss('/system/assets/debugger/phpdebugbar.css');
$css = $this->assets->css('head', ['loading' => 'inline']);
$this->assertContains('div.phpdebugbar', $css);
$this->assertStringContainsString('div.phpdebugbar', $css);
$this->assets->reset();
$this->assets->setCssPipeline(true);
$this->assets->addCss('https://fonts.googleapis.com/css?family=Roboto');
$css = $this->assets->css('head', ['loading' => 'inline']);
$this->assertContains('font-family:\'Roboto\';', $css);
$this->assertStringContainsString('font-family:\'Roboto\';', $css);
//Test adding media queries
$this->assets->reset();
@ -383,16 +383,16 @@ class AssetsTest extends \Codeception\TestCase\Test
$item = reset($array);
$actual = json_encode($item);
$expected = '
{
{
"type":"css",
"elements":{
"elements":{
"asset":"\/test.css",
"asset_type":"css",
"order":0,
"group":"bottom",
"position":"pipeline",
"priority":15,
"attributes":{
"attributes":{
"type":"text\/css",
"rel":"stylesheet",
"loading":"async"
@ -546,8 +546,8 @@ class AssetsTest extends \Codeception\TestCase\Test
$this->assets->addCss('https://fonts.googleapis.com/css?family=Roboto', ['loading' => 'inline']);
$this->assets->addCss('/system/assets/debugger/phpdebugbar.css', ['loading' => 'inline']);
$css = $this->assets->css();
$this->assertContains('font-family: \'Roboto\';', $css);
$this->assertContains('div.phpdebugbar-header', $css);
$this->assertStringContainsString('font-family: \'Roboto\';', $css);
$this->assertStringContainsString('div.phpdebugbar-header', $css);
}
public function testInlinePipeline()
@ -564,8 +564,8 @@ class AssetsTest extends \Codeception\TestCase\Test
$this->assets->addCss('https://fonts.googleapis.com/css?family=Roboto', null, true);
$this->assets->add('/system/assets/debugger/phpdebugbar.css', null, true);
$css = $this->assets->css('head', ['loading' => 'inline']);
$this->assertContains('font-family:\'Roboto\';', $css);
$this->assertContains('div.phpdebugbar', $css);
$this->assertStringContainsString('font-family:\'Roboto\';', $css);
$this->assertStringContainsString('div.phpdebugbar', $css);
}
public function testAddAsyncJs()
@ -661,7 +661,7 @@ class AssetsTest extends \Codeception\TestCase\Test
public function testGetCollections()
{
$this->assertInternalType('array', $this->assets->getCollections());
$this->assertIsArray($this->assets->getCollections());
$this->assertContains('jquery', array_keys($this->assets->getCollections()));
$this->assertContains('system://assets/jquery/jquery-2.x.min.js', $this->assets->getCollections());
}
@ -724,50 +724,50 @@ class AssetsTest extends \Codeception\TestCase\Test
{
$this->assets->addDirCss('/system');
$this->assertInternalType('array', $this->assets->getCss());
$this->assertIsArray($this->assets->getCss());
$this->assertGreaterThan(0, (array) $this->assets->getCss());
$this->assertInternalType('array', $this->assets->getJs());
$this->assertIsArray($this->assets->getJs());
$this->assertCount(0, (array) $this->assets->getJs());
$this->assets->reset();
$this->assets->addDirCss('/system/assets');
$this->assertInternalType('array', $this->assets->getCss());
$this->assertIsArray($this->assets->getCss());
$this->assertGreaterThan(0, (array) $this->assets->getCss());
$this->assertInternalType('array', $this->assets->getJs());
$this->assertIsArray($this->assets->getJs());
$this->assertCount(0, (array) $this->assets->getJs());
$this->assets->reset();
$this->assets->addDirJs('/system');
$this->assertInternalType('array', $this->assets->getCss());
$this->assertIsArray($this->assets->getCss());
$this->assertCount(0, (array) $this->assets->getCss());
$this->assertInternalType('array', $this->assets->getJs());
$this->assertIsArray($this->assets->getJs());
$this->assertGreaterThan(0, (array) $this->assets->getJs());
$this->assets->reset();
$this->assets->addDirJs('/system/assets');
$this->assertInternalType('array', $this->assets->getCss());
$this->assertIsArray($this->assets->getCss());
$this->assertCount(0, (array) $this->assets->getCss());
$this->assertInternalType('array', $this->assets->getJs());
$this->assertIsArray($this->assets->getJs());
$this->assertGreaterThan(0, (array) $this->assets->getJs());
$this->assets->reset();
$this->assets->addDir('/system/assets');
$this->assertInternalType('array', $this->assets->getCss());
$this->assertIsArray($this->assets->getCss());
$this->assertGreaterThan(0, (array) $this->assets->getCss());
$this->assertInternalType('array', $this->assets->getJs());
$this->assertIsArray($this->assets->getJs());
$this->assertGreaterThan(0, (array) $this->assets->getJs());
//Use streams
$this->assets->reset();
$this->assets->addDir('system://assets');
$this->assertInternalType('array', $this->assets->getCss());
$this->assertIsArray($this->assets->getCss());
$this->assertGreaterThan(0, (array) $this->assets->getCss());
$this->assertInternalType('array', $this->assets->getJs());
$this->assertIsArray($this->assets->getJs());
$this->assertGreaterThan(0, (array) $this->assets->getJs());
}
}

View File

@ -16,14 +16,14 @@ class ComposerTest extends \Codeception\TestCase\Test
public function testGetComposerLocation()
{
$composerLocation = Composer::getComposerLocation();
$this->assertInternalType('string', $composerLocation);
$this->assertIsString($composerLocation);
$this->assertSame('/', $composerLocation[0]);
}
public function testGetComposerExecutor()
{
$composerExecutor = Composer::getComposerExecutor();
$this->assertInternalType('string', $composerExecutor);
$this->assertIsString($composerExecutor);
$this->assertSame('/', $composerExecutor[0]);
$this->assertNotNull(strstr($composerExecutor, 'php'));
$this->assertNotNull(strstr($composerExecutor, 'composer'));

View File

@ -20,12 +20,12 @@ class BlueprintTest extends \Codeception\TestCase\Test
/**
* @depends testValidateStrict
* @expectedException Grav\Common\Data\ValidationException
*/
public function testValidateStrictRequired()
{
$blueprint = $this->loadBlueprint('strict');
$this->expectException(\Grav\Common\Data\ValidationException::class);
$blueprint->validate([]);
}
@ -41,7 +41,6 @@ class BlueprintTest extends \Codeception\TestCase\Test
/**
* @depends testValidateStrict
* @expectedException Grav\Common\Data\ValidationException
*/
public function testValidateStrictExtraException()
{
@ -52,6 +51,7 @@ class BlueprintTest extends \Codeception\TestCase\Test
$var = 'system.strict_mode.blueprint_strict_compat';
$config->set($var, false);
$this->expectException(\Grav\Common\Data\ValidationException::class);
$blueprint->validate(['test' => 'string', 'wrong' => 'field']);
$config->set($var, true);

View File

@ -79,7 +79,7 @@ class GpmTest extends \Codeception\TestCase\Test
$dependencies = $this->gpm->calculateMergedDependenciesOfPackages($packages);
$this->assertInternalType('array', $dependencies);
$this->assertIsArray($dependencies);
$this->assertCount(5, $dependencies);
$this->assertSame('>=1.0.10', $dependencies['grav']);
@ -92,7 +92,7 @@ class GpmTest extends \Codeception\TestCase\Test
$packages = ['admin', 'form'];
$dependencies = $this->gpm->calculateMergedDependenciesOfPackages($packages);
$this->assertInternalType('array', $dependencies);
$this->assertIsArray($dependencies);
$this->assertCount(5, $dependencies);
$this->assertSame('>=3.2', $dependencies['errors']);
@ -123,7 +123,7 @@ class GpmTest extends \Codeception\TestCase\Test
$dependencies = $this->gpm->calculateMergedDependenciesOfPackages($packages);
$this->assertInternalType('array', $dependencies);
$this->assertIsArray($dependencies);
$this->assertCount(1, $dependencies);
$this->assertSame('>=4.0', $dependencies['errors']);
@ -252,7 +252,7 @@ class GpmTest extends \Codeception\TestCase\Test
$dependencies = $this->gpm->calculateMergedDependenciesOfPackages($packages);
$this->assertInternalType('array', $dependencies);
$this->assertIsArray($dependencies);
$this->assertCount(7, $dependencies);
$this->assertSame('>=1.0.10', $dependencies['grav']);

View File

@ -138,7 +138,7 @@ class UtilsTest extends \Codeception\TestCase\Test
public function testDateFormats()
{
$dateFormats = Utils::dateFormats();
$this->assertInternalType('array', $dateFormats);
$this->assertIsArray($dateFormats);
$this->assertContainsOnly('string', $dateFormats);
$default_format = $this->grav['config']->get('system.pages.dateformat.default');
@ -270,7 +270,7 @@ class UtilsTest extends \Codeception\TestCase\Test
{
$timezones = Utils::timezones();
$this->assertInternalType('array', $timezones);
$this->assertIsArray($timezones);
$this->assertContainsOnly('string', $timezones);
}
@ -382,8 +382,8 @@ class UtilsTest extends \Codeception\TestCase\Test
public function testGetNonce()
{
$this->assertInternalType('string', Utils::getNonce('test-action'));
$this->assertInternalType('string', Utils::getNonce('test-action', true));
$this->assertIsString(Utils::getNonce('test-action'));
$this->assertIsString(Utils::getNonce('test-action', true));
$this->assertSame(Utils::getNonce('test-action'), Utils::getNonce('test-action'));
$this->assertNotSame(Utils::getNonce('test-action'), Utils::getNonce('test-action2'));
}