Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 75ecf66

Browse files
Merge pull request #113 from symfony-cmf/add_dI_tests
Add DI tests
2 parents ca7715a + 9e13224 commit 75ecf66

8 files changed

+454
-105
lines changed

tests/Unit/DependencyInjection/CmfSonataAdminExtensionTest.php

Lines changed: 2 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -33,118 +33,16 @@ public function testThatBundlesAreConfigured()
3333
{
3434
$this->container->setParameter(
3535
'kernel.bundles',
36-
array(
37-
'CmfSeoBundle' => true,
38-
'CmfRoutingBundle' => true,
39-
'SonataDoctrinePHPCRAdminBundle' => true,
40-
'DoctrinePHPCRBundle' => true,
41-
'BurgovKeyValueFormBundle' => true,
42-
)
43-
);
44-
45-
$this->load([]);
46-
}
47-
48-
public function testSeoBundle()
49-
{
50-
$this->container->setParameter(
51-
'kernel.bundles',
52-
array(
36+
[
5337
'CmfSeoBundle' => true,
5438
'CmfRoutingBundle' => true,
5539
'SonataDoctrinePHPCRAdminBundle' => true,
5640
'DoctrinePHPCRBundle' => true,
5741
'BurgovKeyValueFormBundle' => true,
58-
)
59-
);
60-
61-
$this->load([
62-
'bundles' => [
63-
'seo' => [
64-
'enabled' => true,
65-
'extensions' => [
66-
'metadata' => [
67-
'form_group' => 'seo_group',
68-
'form_tab' => 'seo_tab',
69-
],
70-
],
71-
],
72-
],
73-
]);
74-
75-
$this->assertContainerBuilderHasParameter('cmf_sonata_phpcr_admin_integration.seo.extension.metadata.form_group', 'seo_group');
76-
$this->assertContainerBuilderHasParameter('cmf_sonata_phpcr_admin_integration.seo.extension.metadata.form_tab', 'seo_tab');
77-
}
78-
79-
public function testBlockBundle()
80-
{
81-
$this->container->setParameter(
82-
'kernel.bundles',
83-
[
84-
'CmfBlockBundle' => true,
85-
'CmfMenuBundle' => true,
86-
'CmfRoutingBundle' => true,
87-
'SonataDoctrinePHPCRAdminBundle' => true,
88-
'DoctrinePHPCRBundle' => true,
8942
]
9043
);
9144

92-
$this->load([
93-
'bundles' => [
94-
'block' => [
95-
'enabled' => true,
96-
'basepath' => 'basepath_value',
97-
'menu_basepath' => 'menu_basepath_value',
98-
],
99-
],
100-
]);
101-
102-
$this->assertContainerBuilderHasParameter('cmf_sonata_phpcr_admin_integration.block.persistence.basepath', 'basepath_value');
103-
$this->assertContainerBuilderHasParameter('cmf_sonata_phpcr_admin_integration.block.persistence.menu_basepath', 'menu_basepath_value');
104-
}
105-
106-
public function testCoreDefaults()
107-
{
108-
$this->container->setParameter(
109-
'kernel.bundles',
110-
array(
111-
'CmfRoutingBundle' => true,
112-
'SonataDoctrinePHPCRAdminBundle' => true,
113-
'DoctrinePHPCRBundle' => true,
114-
'CmfCoreBundle' => true,
115-
)
116-
);
117-
118-
$this->load([
119-
'bundles' => [
120-
'core' => [
121-
'enabled' => true,
122-
'extensions' => [
123-
'publishable' => ['form_group' => 'publishable_form'],
124-
'publish_time' => ['form_group' => 'publish_time_form'],
125-
],
126-
],
127-
],
128-
]);
129-
130-
$this->assertContainerBuilderHasParameter(
131-
'cmf_sonata_phpcr_admin_integration.core.extension.publishable.form_group',
132-
'publishable_form'
133-
);
134-
$this->assertContainerBuilderHasParameter(
135-
'cmf_sonata_phpcr_admin_integration.core.extension.publish_time.form_group',
136-
'publish_time_form'
137-
);
138-
139-
$this->assertContainerBuilderHasService(
140-
'cmf_sonata_phpcr_admin_integration.core.extension.publish_workflow.time_period'
141-
);
142-
$this->assertContainerBuilderHasService(
143-
'cmf_sonata_phpcr_admin_integration.core.extension.publish_workflow.publishable'
144-
);
145-
$this->assertContainerBuilderHasService(
146-
'cmf_sonata_phpcr_admin_integration.core.extension.child'
147-
);
45+
$this->load([]);
14846
}
14947

15048
public function testEnhancerExists()
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony CMF package.
5+
*
6+
* (c) 2011-2017 Symfony CMF
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Cmf\Bundle\SonataPhpcrAdminIntegrationBundle\Tests\Unit\DependencyInjection\Factory;
13+
14+
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;
15+
use Symfony\Cmf\Bundle\SonataPhpcrAdminIntegrationBundle\DependencyInjection\CmfSonataPhpcrAdminIntegrationExtension;
16+
17+
/**
18+
* @author Maximilian Berghoff <[email protected]>
19+
*/
20+
abstract class AbstractFactoryTest extends AbstractExtensionTestCase
21+
{
22+
/**
23+
* {@inheritdoc}
24+
*/
25+
protected function getContainerExtensions()
26+
{
27+
return [new CmfSonataPhpcrAdminIntegrationExtension()];
28+
}
29+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony CMF package.
5+
*
6+
* (c) 2011-2017 Symfony CMF
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Cmf\Bundle\SonataPhpcrAdminIntegrationBundle\Tests\Unit\DependencyInjection\Factory;
13+
14+
/**
15+
* @author Maximilian Berghoff <[email protected]>
16+
*/
17+
class BlockAdminFactoryTest extends AbstractFactoryTest
18+
{
19+
public function testParametersBundle()
20+
{
21+
$this->container->setParameter(
22+
'kernel.bundles',
23+
[
24+
'CmfBlockBundle' => true,
25+
'CmfMenuBundle' => true,
26+
'CmfRoutingBundle' => true,
27+
'SonataDoctrinePHPCRAdminBundle' => true,
28+
'DoctrinePHPCRBundle' => true,
29+
]
30+
);
31+
32+
$this->load([
33+
'bundles' => [
34+
'block' => [
35+
'enabled' => true,
36+
'basepath' => 'basepath_value',
37+
'menu_basepath' => 'menu_basepath_value',
38+
'extensions' => [
39+
'block_cache' => [
40+
'form_group' => 'block_group',
41+
'form_tab' => 'block_tab',
42+
],
43+
],
44+
],
45+
],
46+
]);
47+
48+
$this->assertContainerBuilderHasParameter('cmf_sonata_phpcr_admin_integration.block.persistence.basepath', 'basepath_value');
49+
$this->assertContainerBuilderHasParameter('cmf_sonata_phpcr_admin_integration.block.persistence.menu_basepath', 'menu_basepath_value');
50+
$this->assertContainerBuilderHasParameter('cmf_sonata_phpcr_admin_integration.block.extension.block_cache.form_group', 'block_group');
51+
$this->assertContainerBuilderHasParameter('cmf_sonata_phpcr_admin_integration.block.extension.block_cache.form_tab', 'block_tab');
52+
}
53+
54+
public function testAdminServicesBundle()
55+
{
56+
$this->container->setParameter(
57+
'kernel.bundles',
58+
[
59+
'CmfBlockBundle' => true,
60+
'CmfRoutingBundle' => true,
61+
'SonataDoctrinePHPCRAdminBundle' => true,
62+
'DoctrinePHPCRBundle' => true,
63+
]
64+
);
65+
66+
$this->load([
67+
'bundles' => [
68+
'block' => true,
69+
],
70+
]);
71+
72+
$this->assertContainerBuilderHasService('cmf_sonata_phpcr_admin_integration.block.admin_extension.cache');
73+
$this->assertContainerBuilderHasService('cmf_sonata_phpcr_admin_integration.block.simple_admin');
74+
$this->assertContainerBuilderHasService('cmf_sonata_phpcr_admin_integration.block.action_admin');
75+
$this->assertContainerBuilderHasService('cmf_sonata_phpcr_admin_integration.block.container_admin');
76+
$this->assertContainerBuilderHasService('cmf_sonata_phpcr_admin_integration.block.reference_admin');
77+
$this->assertContainerBuilderHasService('cmf_sonata_phpcr_admin_integration.block.string_admin');
78+
}
79+
80+
public function testMenuAdminServicesBundle()
81+
{
82+
$this->container->setParameter(
83+
'kernel.bundles',
84+
[
85+
'CmfBlockBundle' => true,
86+
'CmfMenuBundle' => true,
87+
'CmfRoutingBundle' => true,
88+
'SonataDoctrinePHPCRAdminBundle' => true,
89+
'DoctrinePHPCRBundle' => true,
90+
]
91+
);
92+
93+
$this->load([
94+
'bundles' => [
95+
'block' => [
96+
'enabled' => true,
97+
'enable_menu' => 'auto',
98+
],
99+
],
100+
]);
101+
102+
$this->assertContainerBuilderHasService('cmf_sonata_phpcr_admin_integration.block.menu_admin');
103+
}
104+
}

tests/Unit/DependencyInjection/Factory/ContentAdminFactoryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111

1212
namespace Symfony\Cmf\Bundle\SonataPhpcrAdminIntegrationBundle\Tests\Unit\DependencyInjection\Factory;
1313

14+
use Symfony\Cmf\Bundle\SonataPhpcrAdminIntegrationBundle\DependencyInjection\Factory\ContentAdminFactory;
1415
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
1516
use Symfony\Component\Config\Definition\Processor;
1617
use Symfony\Component\DependencyInjection\ContainerBuilder;
1718
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
18-
use Symfony\Cmf\Bundle\SonataPhpcrAdminIntegrationBundle\DependencyInjection\Factory\ContentAdminFactory;
1919

2020
/**
2121
* @author Wouter de Jong <[email protected]>
22+
* @author Maximilian Berghoff <[email protected]>
2223
*/
2324
class ContentAdminFactoryTest extends \PHPUnit_Framework_TestCase
2425
{
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony CMF package.
5+
*
6+
* (c) 2011-2017 Symfony CMF
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Cmf\Bundle\SonataPhpcrAdminIntegrationBundle\Tests\Unit\DependencyInjection\Factory;
13+
14+
/**
15+
* @author Maximilian Berghoff <[email protected]>
16+
*/
17+
class CoreAdminFactoryTest extends AbstractFactoryTest
18+
{
19+
public function testParametersBundle()
20+
{
21+
$this->container->setParameter('kernel.bundles', [
22+
'CmfCoreBundle' => true,
23+
'SonataDoctrinePHPCRAdminBundle' => true,
24+
'CmfSonataPhpcrAdminIntegrationBundle' => true,
25+
]);
26+
$this->load([
27+
'bundles' => [
28+
'core' => [
29+
'enabled' => true,
30+
'extensions' => [
31+
'publishable' => ['form_group' => 'publishable_form'],
32+
'publish_time' => ['form_group' => 'publish_time_form'],
33+
],
34+
],
35+
],
36+
]);
37+
38+
$this->assertContainerBuilderHasParameter(
39+
'cmf_sonata_phpcr_admin_integration.core.extension.publishable.form_group',
40+
'publishable_form'
41+
);
42+
$this->assertContainerBuilderHasParameter(
43+
'cmf_sonata_phpcr_admin_integration.core.extension.publish_time.form_group',
44+
'publish_time_form'
45+
);
46+
}
47+
48+
public function testAdminServicesBundle()
49+
{
50+
$this->container->setParameter(
51+
'kernel.bundles',
52+
[
53+
'CmfRoutingBundle' => true,
54+
'SonataDoctrinePHPCRAdminBundle' => true,
55+
'DoctrinePHPCRBundle' => true,
56+
'CmfCoreBundle' => true,
57+
]
58+
);
59+
60+
$this->load([
61+
'bundles' => [
62+
'core' => true,
63+
],
64+
]);
65+
66+
$this->assertContainerBuilderHasService(
67+
'cmf_sonata_phpcr_admin_integration.core.extension.publish_workflow.time_period'
68+
);
69+
$this->assertContainerBuilderHasService(
70+
'cmf_sonata_phpcr_admin_integration.core.extension.publish_workflow.publishable'
71+
);
72+
$this->assertContainerBuilderHasService(
73+
'cmf_sonata_phpcr_admin_integration.core.extension.child'
74+
);
75+
}
76+
}

0 commit comments

Comments
 (0)