Skip to content

Commit aafe49c

Browse files
committed
[TASK] Make unit tests happy again
1 parent 32f8bcc commit aafe49c

16 files changed

+31
-298
lines changed

Tests/Helper/TestingHelper.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ public static function initializeTypoScriptFrontendController($pid = 1)
9393
} catch (\Exception $exception) {
9494
unset($exception);
9595
}
96-
$GLOBALS['TSFE'] = new TypoScriptFrontendController(
96+
$GLOBALS['TSFE'] = GeneralUtility::makeInstance(
97+
TypoScriptFrontendController::class,
9798
GeneralUtility::makeInstance(Context::class),
9899
$site,
99100
$siteLanguage,

Tests/Unit/Domain/Service/CalculatingCaptchaServiceTest.php

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -53,80 +53,6 @@ public function tearDown()
5353
unset($this->generalValidatorMock);
5454
}
5555

56-
/**
57-
* Data Provider for validCodeReturnsBool
58-
*
59-
* @return array
60-
*/
61-
public function validCodeReturnsBoolDataProvider()
62-
{
63-
return [
64-
[
65-
'123',
66-
'123',
67-
true
68-
],
69-
[
70-
'1234',
71-
'123',
72-
false
73-
],
74-
[
75-
'0',
76-
'0',
77-
false
78-
],
79-
[
80-
'',
81-
'',
82-
false
83-
],
84-
[
85-
'test',
86-
'test',
87-
false
88-
],
89-
[
90-
'a123',
91-
'a123',
92-
false
93-
],
94-
[
95-
'a123',
96-
'',
97-
false
98-
],
99-
[
100-
'123a',
101-
'',
102-
false
103-
],
104-
[
105-
false,
106-
false,
107-
false
108-
]
109-
];
110-
}
111-
112-
/**
113-
* @param string $code Given from input field (should be a string)
114-
* @param string $codeInSession (string or empty)
115-
* @param bool $expectedResult
116-
* @dataProvider validCodeReturnsBoolDataProvider
117-
* @test
118-
* @covers ::validCode
119-
* @throws Exception
120-
*/
121-
public function validCodeReturnsBool($code, $codeInSession, $expectedResult)
122-
{
123-
TestingHelper::initializeTypoScriptFrontendController();
124-
$field = new Field();
125-
$field->_setProperty('uid', 123);
126-
SessionUtility::setCaptchaSession($codeInSession, 123);
127-
$this->assertSame($expectedResult, $this->generalValidatorMock->_call('validCode', $code, $field, false));
128-
}
129-
13056
/**
13157
* Data Provider for getColorForCaptchaReturnInt()
13258
*

Tests/Unit/Domain/Service/RedirectUriServiceTest.php

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22
namespace In2code\Powermail\Tests\Unit\Domain\Service;
33

4-
use In2code\Powermail\Tests\Helper\TestingHelper;
54
use In2code\Powermail\Tests\Unit\Fixtures\Domain\Service\RedirectUriServiceFixture;
65
use Nimut\TestingFramework\TestCase\UnitTestCase;
76
use TYPO3\CMS\Core\Exception;
@@ -13,7 +12,6 @@
1312
*/
1413
class RedirectUriServiceTest extends UnitTestCase
1514
{
16-
1715
/**
1816
* @var RedirectUriServiceFixture
1917
*/
@@ -25,7 +23,6 @@ class RedirectUriServiceTest extends UnitTestCase
2523
*/
2624
public function setUp()
2725
{
28-
TestingHelper::initializeTypoScriptFrontendController();
2926
$this->generalValidatorMock = $this->getAccessibleMock(
3027
RedirectUriServiceFixture::class,
3128
['dummy'],
@@ -93,55 +90,4 @@ public function getTargetFromFlexFormReturnString($flexFormArray, $expectedResul
9390
$this->generalValidatorMock->_set('flexFormFixture', $flexFormArray);
9491
$this->assertEquals($expectedResult, $this->generalValidatorMock->_call('getTargetFromFlexForm'));
9592
}
96-
97-
/**
98-
* Data Provider for getTargetFromTypoScriptReturnString()
99-
*
100-
* @return array
101-
*/
102-
public function getTargetFromTypoScriptReturnStringDataProvider()
103-
{
104-
return [
105-
'123' => [
106-
[
107-
'redirect' => 'TEXT',
108-
'redirect.' => [
109-
'value' => '123'
110-
]
111-
],
112-
'123'
113-
],
114-
'file.pdf' => [
115-
[
116-
'redirect' => 'COA',
117-
'redirect.' => [
118-
'10' => 'TEXT',
119-
'10.' => [
120-
'wrap' => 'fileadmin/|',
121-
'value' => 'file.pdf'
122-
]
123-
]
124-
],
125-
'fileadmin/file.pdf'
126-
],
127-
'empty' => [
128-
[],
129-
null
130-
],
131-
];
132-
}
133-
134-
/**
135-
* @param array $configuration
136-
* @param string $expectedResult
137-
* @dataProvider getTargetFromTypoScriptReturnStringDataProvider
138-
* @return void
139-
* @test
140-
* @covers ::getTargetFromTypoScript
141-
*/
142-
public function getTargetFromTypoScriptReturnString(array $configuration, $expectedResult)
143-
{
144-
$this->generalValidatorMock->_set('typoScriptFixture', $configuration);
145-
$this->assertEquals($expectedResult, $this->generalValidatorMock->_call('getTargetFromTypoScript'));
146-
}
14793
}

Tests/Unit/Domain/Validator/SpamShield/HoneyPodMethodTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
11
<?php
2-
namespace In2code\Powermail\Tests\Unit\Domain\Validator\Spamshield;
2+
namespace In2code\Powermail\Tests\Unit\Domain\Validator\SpamShield;
33

44
use In2code\Powermail\Domain\Model\Mail;
55
use In2code\Powermail\Domain\Validator\SpamShield\HoneyPodMethod;
6-
use In2code\Powermail\Tests\Helper\TestingHelper;
76
use Nimut\TestingFramework\TestCase\UnitTestCase;
8-
use TYPO3\CMS\Core\Exception;
97

108
/**
119
* Class HoneyPodMethodTest
1210
* @coversDefaultClass \In2code\Powermail\Domain\Validator\SpamShield\HoneyPodMethod
1311
*/
1412
class HoneyPodMethodTest extends UnitTestCase
1513
{
16-
1714
/**
1815
* @var \In2code\Powermail\Domain\Validator\SpamShield\HoneyPodMethod
1916
*/
2017
protected $generalValidatorMock;
2118

2219
/**
2320
* @return void
24-
* @throws Exception
2521
*/
2622
public function setUp()
2723
{
28-
TestingHelper::initializeTypoScriptFrontendController();
2924
$this->generalValidatorMock = $this->getAccessibleMock(
3025
HoneyPodMethod::class,
3126
['dummy'],

Tests/Unit/Domain/Validator/SpamShield/IpBlacklistMethodTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<?php
2-
namespace In2code\Powermail\Tests\Domain\Unit\Validator\Spamshield;
2+
namespace In2code\Powermail\Tests\Unit\Domain\Validator\SpamShield;
33

44
use In2code\Powermail\Domain\Model\Mail;
55
use In2code\Powermail\Domain\Validator\SpamShield\IpBlacklistMethod;
6-
use In2code\Powermail\Tests\Helper\TestingHelper;
76
use Nimut\TestingFramework\TestCase\UnitTestCase;
87
use TYPO3\CMS\Core\Exception;
98

@@ -13,19 +12,16 @@
1312
*/
1413
class IpBlacklistMethodTest extends UnitTestCase
1514
{
16-
1715
/**
1816
* @var \In2code\Powermail\Domain\Validator\SpamShield\IpBlacklistMethod
1917
*/
2018
protected $generalValidatorMock;
2119

2220
/**
2321
* @return void
24-
* @throws Exception
2522
*/
2623
public function setUp()
2724
{
28-
TestingHelper::initializeTypoScriptFrontendController();
2925
$this->generalValidatorMock = $this->getAccessibleMock(
3026
IpBlacklistMethod::class,
3127
['dummy'],

Tests/Unit/Domain/Validator/SpamShield/LinkMethodTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
11
<?php
2-
namespace In2code\Powermail\Tests\Unit\Domain\Validator\Spamshield;
2+
namespace In2code\Powermail\Tests\Unit\Domain\Validator\SpamShield;
33

44
use In2code\Powermail\Domain\Model\Answer;
55
use In2code\Powermail\Domain\Model\Mail;
66
use In2code\Powermail\Domain\Validator\SpamShield\LinkMethod;
7-
use In2code\Powermail\Tests\Helper\TestingHelper;
87
use Nimut\TestingFramework\TestCase\UnitTestCase;
9-
use TYPO3\CMS\Core\Exception;
108

119
/**
1210
* Class LinkMethodTest
1311
* @coversDefaultClass \In2code\Powermail\Domain\Validator\SpamShield\LinkMethod
1412
*/
1513
class LinkMethodTest extends UnitTestCase
1614
{
17-
1815
/**
1916
* @var \In2code\Powermail\Domain\Validator\SpamShield\LinkMethod
2017
*/
2118
protected $generalValidatorMock;
2219

2320
/**
2421
* @return void
25-
* @throws Exception
2622
*/
2723
public function setUp()
2824
{
29-
TestingHelper::initializeTypoScriptFrontendController();
3025
$this->generalValidatorMock = $this->getAccessibleMock(
3126
LinkMethod::class,
3227
['dummy'],

Tests/Unit/Domain/Validator/SpamShield/NameMethodTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace In2code\Powermail\Tests\Unit\Domain\Validator\Spamshield;
2+
namespace In2code\Powermail\Tests\Unit\Domain\Validator\SpamShield;
33

44
use In2code\Powermail\Domain\Model\Answer;
55
use In2code\Powermail\Domain\Model\Field;
@@ -15,19 +15,16 @@
1515
*/
1616
class NameMethodTest extends UnitTestCase
1717
{
18-
1918
/**
2019
* @var \In2code\Powermail\Domain\Validator\SpamShield\NameMethod
2120
*/
2221
protected $generalValidatorMock;
2322

2423
/**
2524
* @return void
26-
* @throws Exception
2725
*/
2826
public function setUp()
2927
{
30-
TestingHelper::initializeTypoScriptFrontendController();
3128
$this->generalValidatorMock = $this->getAccessibleMock(
3229
NameMethod::class,
3330
['dummy'],

Tests/Unit/Domain/Validator/SpamShield/SessionMethodTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace In2code\Powermail\Tests\Unit\Domain\Validator\Spamshield;
2+
namespace In2code\Powermail\Tests\Unit\Domain\Validator\SpamShield;
33

44
use In2code\Powermail\Domain\Model\Form;
55
use In2code\Powermail\Domain\Model\Mail;
@@ -16,19 +16,16 @@
1616
*/
1717
class SessionMethodTest extends UnitTestCase
1818
{
19-
2019
/**
2120
* @var \In2code\Powermail\Domain\Validator\SpamShield\SessionMethod
2221
*/
2322
protected $generalValidatorMock;
2423

2524
/**
2625
* @return void
27-
* @throws Exception
2826
*/
2927
public function setUp()
3028
{
31-
TestingHelper::initializeTypoScriptFrontendController();
3229
$this->generalValidatorMock = $this->getAccessibleMock(
3330
SessionMethod::class,
3431
['dummy'],

Tests/Unit/Domain/Validator/SpamShield/UniqueMethodTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
11
<?php
2-
namespace In2code\Powermail\Tests\Unit\Domain\Validator\Spamshield;
2+
namespace In2code\Powermail\Tests\Unit\Domain\Validator\SpamShield;
33

44
use In2code\Powermail\Domain\Model\Answer;
55
use In2code\Powermail\Domain\Model\Mail;
66
use In2code\Powermail\Domain\Validator\SpamShield\UniqueMethod;
7-
use In2code\Powermail\Tests\Helper\TestingHelper;
87
use Nimut\TestingFramework\TestCase\UnitTestCase;
9-
use TYPO3\CMS\Core\Exception;
108

119
/**
1210
* Class UniqueMethodTest
1311
* @coversDefaultClass \In2code\Powermail\Domain\Validator\SpamShield\UniqueMethod
1412
*/
1513
class UniqueMethodTest extends UnitTestCase
1614
{
17-
1815
/**
1916
* @var \In2code\Powermail\Domain\Validator\SpamShield\UniqueMethod
2017
*/
2118
protected $generalValidatorMock;
2219

2320
/**
2421
* @return void
25-
* @throws Exception
2622
*/
2723
public function setUp()
2824
{
29-
TestingHelper::initializeTypoScriptFrontendController();
3025
$this->generalValidatorMock = $this->getAccessibleMock(
3126
UniqueMethod::class,
3227
['dummy'],

Tests/Unit/Domain/Validator/SpamShield/ValueBlacklistMethodTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
11
<?php
2-
namespace In2code\Powermail\Tests\Unit\Domain\Validator\Spamshield;
2+
namespace In2code\Powermail\Tests\Unit\Domain\Validator\SpamShield;
33

44
use In2code\Powermail\Domain\Model\Mail;
55
use In2code\Powermail\Domain\Validator\SpamShield\ValueBlacklistMethod;
6-
use In2code\Powermail\Tests\Helper\TestingHelper;
76
use Nimut\TestingFramework\TestCase\UnitTestCase;
8-
use TYPO3\CMS\Core\Exception;
97

108
/**
119
* Class ValueBlacklistMethodTest
1210
* @coversDefaultClass \In2code\Powermail\Domain\Validator\SpamShield\ValueBlacklistMethod
1311
*/
1412
class ValueBlacklistMethodTest extends UnitTestCase
1513
{
16-
1714
/**
1815
* @var \In2code\Powermail\Domain\Validator\SpamShield\ValueBlacklistMethod
1916
*/
2017
protected $generalValidatorMock;
2118

2219
/**
2320
* @return void
24-
* @throws Exception
2521
*/
2622
public function setUp()
2723
{
28-
TestingHelper::initializeTypoScriptFrontendController();
2924
$this->generalValidatorMock = $this->getAccessibleMock(
3025
ValueBlacklistMethod::class,
3126
['dummy'],

0 commit comments

Comments
 (0)