Skip to content

Commit e90bf36

Browse files
committed
Console Bundle tests and bugs fixed
1 parent 80e3c69 commit e90bf36

File tree

12 files changed

+206
-21
lines changed

12 files changed

+206
-21
lines changed

src/Bundle/Console/Resources/config/commands.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,6 @@ services:
5252
tags:
5353
- {name: 'console.command'}
5454

55-
Jose\Component\Console\JKULoaderCommand:
56-
tags:
57-
- {name: 'console.command'}
58-
59-
Jose\Component\Console\X5ULoaderCommand:
60-
tags:
61-
- {name: 'console.command'}
62-
6355
Jose\Component\Console\KeyAnalyzerCommand:
6456
tags:
6557
- {name: 'console.command'}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* The MIT License (MIT)
7+
*
8+
* Copyright (c) 2014-2017 Spomky-Labs
9+
*
10+
* This software may be modified and distributed under the terms
11+
* of the MIT license. See the LICENSE file for details.
12+
*/
13+
14+
use Symfony\Component\Config\Loader\LoaderInterface;
15+
use Symfony\Component\HttpKernel\Kernel;
16+
17+
/**
18+
* Class AppKernel.
19+
*/
20+
final class AppKernel extends Kernel
21+
{
22+
/**
23+
* {@inheritdoc}
24+
*/
25+
public function registerBundles()
26+
{
27+
$bundles = [
28+
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
29+
new Jose\Bundle\JoseFramework\JoseFrameworkBundle(),
30+
new Jose\Bundle\Console\ConsoleBundle(),
31+
32+
new Jose\Bundle\Console\Tests\TestBundle\TestBundle(),
33+
];
34+
35+
return $bundles;
36+
}
37+
38+
/**
39+
* {@inheritdoc}
40+
*/
41+
public function getCacheDir()
42+
{
43+
return sys_get_temp_dir().'/Jose/Bundle/Test';
44+
}
45+
46+
/**
47+
* {@inheritdoc}
48+
*/
49+
public function registerContainerConfiguration(LoaderInterface $loader)
50+
{
51+
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
52+
}
53+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* The MIT License (MIT)
7+
*
8+
* Copyright (c) 2014-2017 Spomky-Labs
9+
*
10+
* This software may be modified and distributed under the terms
11+
* of the MIT license. See the LICENSE file for details.
12+
*/
13+
14+
namespace Jose\Bundle\Console\Tests;
15+
16+
use Symfony\Bundle\FrameworkBundle\Console\Application;
17+
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
18+
19+
/**
20+
* @group Bundle
21+
* @group Functional
22+
*/
23+
final class ConsoleTest extends KernelTestCase
24+
{
25+
public function testAllCommandsAreAvailable()
26+
{
27+
$expectedCommands = [
28+
'keyset:add:key',
29+
'key:generate:ec',
30+
'keyset:generate:ec',
31+
'key:thumbprint',
32+
'key:analyze',
33+
'key:load:key',
34+
'keyset:analyze',
35+
'keyset:merge',
36+
'key:generate:oct',
37+
'keyset:generate:oct',
38+
'key:generate:okp',
39+
'keyset:generate:okp',
40+
'key:optimize',
41+
'key:load:p12',
42+
'key:convert:pkcs1',
43+
'keyset:convert:public',
44+
'keyset:rotate',
45+
'key:generate:rsa',
46+
'keyset:generate:rsa',
47+
'key:load:x509'
48+
];
49+
self::bootKernel();
50+
$application = new Application(self::$kernel);
51+
52+
self::assertEmpty(array_diff($expectedCommands, array_keys($application->all())));
53+
}
54+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* The MIT License (MIT)
7+
*
8+
* Copyright (c) 2014-2017 Spomky-Labs
9+
*
10+
* This software may be modified and distributed under the terms
11+
* of the MIT license. See the LICENSE file for details.
12+
*/
13+
14+
namespace Jose\Bundle\Console\Tests\TestBundle\DependencyInjection;
15+
16+
use Symfony\Component\Config\FileLocator;
17+
use Symfony\Component\DependencyInjection\ContainerBuilder;
18+
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
19+
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
20+
21+
/**
22+
* Class TestExtension.
23+
*/
24+
final class TestExtension extends Extension
25+
{
26+
/**
27+
* {@inheritdoc}
28+
*/
29+
public function load(array $configs, ContainerBuilder $container)
30+
{
31+
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
32+
$loader->load('services.yml');
33+
}
34+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
services:
2+
_defaults:
3+
autowire: true
4+
autoconfigure: true
5+
public: true
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* The MIT License (MIT)
7+
*
8+
* Copyright (c) 2014-2017 Spomky-Labs
9+
*
10+
* This software may be modified and distributed under the terms
11+
* of the MIT license. See the LICENSE file for details.
12+
*/
13+
14+
namespace Jose\Bundle\Console\Tests\TestBundle;
15+
16+
use Symfony\Component\HttpKernel\Bundle\Bundle;
17+
18+
/**
19+
* Class TestBundle.
20+
*/
21+
final class TestBundle extends Bundle
22+
{
23+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
framework:
2+
test: ~
3+
secret: test
4+
session:
5+
storage_id: session.storage.mock_file
6+
router:
7+
resource: "%kernel.root_dir%/config/routing.yml"
8+
strict_requirements: ~
9+
fragments: ~
10+
http_method_override: true

src/Bundle/Console/Tests/config/routing.yml

Whitespace-only changes.

src/Bundle/Console/composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
"web-token/jwt-key-mgmt": "^1.0@dev"
2828
},
2929
"require-dev": {
30+
"symfony/framework-bundle": "^3.3",
31+
"symfony/yaml": "^3.3",
32+
"symfony/browser-kit": "^3.3",
3033
"phpunit/phpunit": "^6.0"
3134
},
3235
"extra": {

src/Bundle/Console/phpunit.xml.dist

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
<directory>./Tests/</directory>
1616
</testsuite>
1717
</testsuites>
18-
18+
<php>
19+
<ini name="error_reporting" value="-1" />
20+
<server name="KERNEL_DIR" value="./Tests/" />
21+
</php>
1922
<filter>
2023
<whitelist>
2124
<directory suffix=".php">./</directory>

0 commit comments

Comments
 (0)