From 229f0035ad9cba3837735c3fec6a0de7bccd1448 Mon Sep 17 00:00:00 2001 From: Jan Helke <typo3@helke.de> Date: Mon, 28 May 2018 13:41:56 +0200 Subject: [PATCH] [TASK] Make Tests/Unit/Tree/ notice free Releases: master Resolves: #85089 Change-Id: Idb85307b51e609f147ccfeacce710256778f96a2 Reviewed-on: https://review.typo3.org/57060 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com> Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> --- .../TreeDataProviderFactory.php | 2 +- .../TreeDataProviderFactoryTest.php | 27 +++++++++---------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/typo3/sysext/core/Classes/Tree/TableConfiguration/TreeDataProviderFactory.php b/typo3/sysext/core/Classes/Tree/TableConfiguration/TreeDataProviderFactory.php index be664edabf06..cab4fb412cea 100644 --- a/typo3/sysext/core/Classes/Tree/TableConfiguration/TreeDataProviderFactory.php +++ b/typo3/sysext/core/Classes/Tree/TableConfiguration/TreeDataProviderFactory.php @@ -34,7 +34,7 @@ class TreeDataProviderFactory { /** @var $dataProvider \TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeDataProvider */ $dataProvider = null; - if (!isset($tcaConfiguration['treeConfig']) | !is_array($tcaConfiguration['treeConfig'])) { + if (!isset($tcaConfiguration['treeConfig']) || !is_array($tcaConfiguration['treeConfig'])) { throw new \InvalidArgumentException('TCA Tree configuration is invalid: "treeConfig" array is missing', 1288215890); } diff --git a/typo3/sysext/core/Tests/Unit/Tree/TableConfiguration/TreeDataProviderFactoryTest.php b/typo3/sysext/core/Tests/Unit/Tree/TableConfiguration/TreeDataProviderFactoryTest.php index c4ef6c066c60..a9d84c71ebde 100644 --- a/typo3/sysext/core/Tests/Unit/Tree/TableConfiguration/TreeDataProviderFactoryTest.php +++ b/typo3/sysext/core/Tests/Unit/Tree/TableConfiguration/TreeDataProviderFactoryTest.php @@ -1,4 +1,5 @@ <?php +declare(strict_types = 1); namespace TYPO3\CMS\Core\Tests\Unit\Tree\TableConfiguration; /* @@ -17,23 +18,19 @@ namespace TYPO3\CMS\Core\Tests\Unit\Tree\TableConfiguration; use TYPO3\CMS\Core\Tests\Unit\Tree\TableConfiguration\Fixtures\TreeDataProviderFixture; use TYPO3\CMS\Core\Tests\Unit\Tree\TableConfiguration\Fixtures\TreeDataProviderWithConfigurationFixture; use TYPO3\CMS\Core\Tree\TableConfiguration\TreeDataProviderFactory; +use TYPO3\TestingFramework\Core\Unit\UnitTestCase; /** * Test case */ -class TreeDataProviderFactoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase +class TreeDataProviderFactoryTest extends UnitTestCase { - /** - * Subject is not notice free, disable E_NOTICES - */ - protected static $suppressNotices = true; - /** * @var TreeDataProviderFactory */ protected $subject; - protected function setUp() + protected function setUp(): void { $this->subject = new TreeDataProviderFactory(); $GLOBALS['TCA'] = []; @@ -46,7 +43,7 @@ class TreeDataProviderFactoryTest extends \TYPO3\TestingFramework\Core\Unit\Unit /** * @return array */ - public function invalidConfigurationDataProvider() + public function invalidConfigurationDataProvider(): array { return [ 'Empty Configuration' => [[], 1288215890], @@ -99,22 +96,22 @@ class TreeDataProviderFactoryTest extends \TYPO3\TestingFramework\Core\Unit\Unit /** * @param array $tcaConfiguration - * @param string $expectedExceptionCode + * @param int $expectedExceptionCode * @test * @dataProvider invalidConfigurationDataProvider */ - public function factoryThrowsExceptionIfInvalidConfigurationIsGiven(array $tcaConfiguration, $expectedExceptionCode) + public function factoryThrowsExceptionIfInvalidConfigurationIsGiven(array $tcaConfiguration, int $expectedExceptionCode): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionCode($expectedExceptionCode); - $this->subject->getDataProvider($tcaConfiguration, 'foo', 'bar', ['uid' => 1]); + $this->subject::getDataProvider($tcaConfiguration, 'foo', 'bar', ['uid' => 1]); } /** * @test */ - public function configuredDataProviderClassIsInstantiated() + public function configuredDataProviderClassIsInstantiated(): void { $dataProviderMockClassName = TreeDataProviderFixture::class; @@ -122,7 +119,7 @@ class TreeDataProviderFactoryTest extends \TYPO3\TestingFramework\Core\Unit\Unit 'treeConfig' => ['dataProvider' => $dataProviderMockClassName], 'internal_type' => 'foo' ]; - $dataProvider = $this->subject->getDataProvider($tcaConfiguration, 'foo', 'bar', ['uid' => 1]); + $dataProvider = $this->subject::getDataProvider($tcaConfiguration, 'foo', 'bar', ['uid' => 1]); $this->assertInstanceOf($dataProviderMockClassName, $dataProvider); } @@ -130,7 +127,7 @@ class TreeDataProviderFactoryTest extends \TYPO3\TestingFramework\Core\Unit\Unit /** * @test */ - public function configuredDataProviderClassIsInstantiatedWithTcaConfigurationInConstructor() + public function configuredDataProviderClassIsInstantiatedWithTcaConfigurationInConstructor(): void { $dataProviderMockClassName = TreeDataProviderWithConfigurationFixture::class; @@ -142,6 +139,6 @@ class TreeDataProviderFactoryTest extends \TYPO3\TestingFramework\Core\Unit\Unit ]; $this->expectException(\RuntimeException::class); $this->expectExceptionCode(1438875249); - $this->subject->getDataProvider($tcaConfiguration, 'foo', 'bar', ['uid' => 1]); + $this->subject::getDataProvider($tcaConfiguration, 'foo', 'bar', ['uid' => 1]); } } -- GitLab