Skip to content

Commit 1e899a6

Browse files
committed
Update php unit test
1 parent c7c6b72 commit 1e899a6

File tree

3 files changed

+41
-17
lines changed

3 files changed

+41
-17
lines changed

tests/Test/Attribute/TableMultiAttributeTypeFactoryTest.php

+12-4
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@
1717
* @author David Molineus <[email protected]>
1818
* @author Ingolf Steinhardt <[email protected]>
1919
* @author Stefan Heimes <[email protected]>
20+
* @author Sven Baumann <[email protected]>
2021
* @copyright 2012-2022 The MetaModels team.
2122
* @license https://github.com/MetaModels/attribute_tablemulti/blob/master/LICENSE LGPL-3.0-or-later
2223
* @filesource
2324
*/
2425

2526
namespace MetaModels\AttributeTableMultiBundle\Test\Attribute;
2627

28+
use Contao\CoreBundle\Framework\Adapter;
29+
use Contao\StringUtil;
30+
use Contao\Validator;
2731
use Doctrine\DBAL\Connection;
2832
use MetaModels\Attribute\IAttributeTypeFactory;
2933
use MetaModels\AttributeTableMultiBundle\Attribute\AttributeTypeFactory;
@@ -89,9 +93,11 @@ private function mockConnection()
8993
*/
9094
protected function getAttributeFactories()
9195
{
92-
$connection = $this->mockConnection();
96+
$connection = $this->mockConnection();
97+
$stringUtil = new Adapter(StringUtil::class);
98+
$validator = new Adapter(Validator::class);
9399

94-
return array(new AttributeTypeFactory($connection));
100+
return array(new AttributeTypeFactory($connection, $stringUtil, $validator));
95101
}
96102

97103
/**
@@ -101,9 +107,11 @@ protected function getAttributeFactories()
101107
*/
102108
public function testCreateAttribute()
103109
{
104-
$connection = $this->mockConnection();
110+
$connection = $this->mockConnection();
111+
$stringUtil = new Adapter(StringUtil::class);
112+
$validator = new Adapter(Validator::class);
105113

106-
$factory = new AttributeTypeFactory($connection);
114+
$factory = new AttributeTypeFactory($connection, $stringUtil, $validator);
107115
$values = array(
108116
'tabletext_cols' => ''
109117
);

tests/Test/Attribute/TableMultiTest.php

+14-1
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@
1818
* @author David Molineus <[email protected]>
1919
* @author Ingolf Steinhardt <[email protected]>
2020
* @author Stefan Heimes <[email protected]>
21+
* @author Sven Baumann <[email protected]>
2122
* @copyright 2012-2022 The MetaModels team.
2223
* @license https://github.com/MetaModels/attribute_tablemulti/blob/master/LICENSE LGPL-3.0-or-later
2324
* @filesource
2425
*/
2526

2627
namespace MetaModels\AttributeTableMultiBundle\Test\Attribute;
2728

29+
use Contao\CoreBundle\Framework\Adapter;
30+
use Contao\StringUtil;
31+
use Contao\Validator;
2832
use Doctrine\DBAL\Connection;
2933
use MetaModels\AttributeTableMultiBundle\Attribute\TableMulti;
3034
use PHPUnit\Framework\TestCase;
@@ -86,7 +90,16 @@ private function mockConnection()
8690
*/
8791
public function testInstantiation()
8892
{
89-
$text = new TableMulti($this->mockMetaModel('en', 'en'), [], $this->mockConnection());
93+
$stringUtil = new Adapter(StringUtil::class);
94+
$validator = new Adapter(Validator::class);
95+
96+
$text = new TableMulti(
97+
$this->mockMetaModel('en', 'en'),
98+
[],
99+
$this->mockConnection(),
100+
$stringUtil,
101+
$validator
102+
);
90103
$this->assertInstanceOf('MetaModels\Attribute\TableMulti\TableMulti', $text);
91104
}
92105
}

tests/Test/DependencyInjection/MetaModelsAttributeTableMultiExtensionTest.php

+15-12
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* @author David Molineus <[email protected]>
1717
* @author Stefan Heimes <[email protected]>
1818
* @author Ingolf Steinhardt <[email protected]>
19+
* @author Sven Baumann <[email protected]>
1920
* @copyright 2012-2022 The MetaModels team.
2021
* @license https://github.com/MetaModels/attribute_tablemulti/blob/master/LICENSE LGPL-3.0-or-later
2122
* @filesource
@@ -29,6 +30,7 @@
2930
use Symfony\Component\DependencyInjection\ContainerBuilder;
3031
use Symfony\Component\DependencyInjection\Definition;
3132
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
33+
use MetaModels\AttributeTableMultiBundle\Migration\ChangeTableNameMigration;
3234

3335
/**
3436
* This test case test the extension.
@@ -60,20 +62,21 @@ public function testFactoryIsRegistered()
6062
$container = $this->getMockBuilder(ContainerBuilder::class)->getMock();
6163

6264
$container
63-
->expects($this->once())
6465
->method('setDefinition')
65-
->with(
66-
'metamodels.attribute_tablemulti.factory',
67-
$this->callback(
68-
function ($value) {
69-
/** @var Definition $value */
70-
$this->assertInstanceOf(Definition::class, $value);
71-
$this->assertEquals(AttributeTypeFactory::class, $value->getClass());
72-
$this->assertCount(1, $value->getTag('metamodels.attribute_factory'));
66+
->withConsecutive(
67+
[
68+
'metamodels.attribute_tablemulti.factory',
69+
$this->callback(
70+
function ($value) {
71+
/** @var Definition $value */
72+
$this->assertInstanceOf(Definition::class, $value);
73+
$this->assertEquals(AttributeTypeFactory::class, $value->getClass());
74+
$this->assertCount(1, $value->getTag('metamodels.attribute_factory'));
7375

74-
return true;
75-
}
76-
)
76+
return true;
77+
}
78+
)
79+
]
7780
);
7881

7982
$extension = new MetaModelsAttributeTableMultiExtension();

0 commit comments

Comments
 (0)