|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* This file is part of the FreshDoctrineEnumBundle |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Artem Genvald <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Fresh\DoctrineEnumBundle\Tests\Util { |
|
12
|
|
|
|
|
13
|
|
|
use Fresh\DoctrineEnumBundle\Tests\Fixtures\DBAL\Types\BasketballPositionType; |
|
14
|
|
|
use Fresh\DoctrineEnumBundle\Util\LegacyFormHelper; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* LegacyFormHelperTest |
|
18
|
|
|
* |
|
19
|
|
|
* @author Jaik Dean <[email protected]> |
|
20
|
|
|
* |
|
21
|
|
|
* @coversClass \Fresh\DoctrineEnumBundle\Util\LegacyFormHelper |
|
22
|
|
|
*/ |
|
23
|
|
|
class LegacyFormHelperTest extends \PHPUnit_Framework_TestCase |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* Test that the helper identifies whether we’re running a legacy |
|
27
|
|
|
* version of Symfony. |
|
28
|
|
|
*/ |
|
29
|
|
|
public function testIsLegacy() |
|
30
|
|
|
{ |
|
31
|
|
|
global $LegacyFormHelperTest_legacySymfonyVersion; |
|
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
$LegacyFormHelperTest_legacySymfonyVersion = true; |
|
34
|
|
|
$this->assertEquals(true, LegacyFormHelper::isLegacy()); |
|
35
|
|
|
|
|
36
|
|
|
$LegacyFormHelperTest_legacySymfonyVersion = false; |
|
37
|
|
|
$this->assertEquals(false, LegacyFormHelper::isLegacy()); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Test that the correct form field type is returned for current and legacy |
|
42
|
|
|
* versions of Symfony. |
|
43
|
|
|
*/ |
|
44
|
|
|
public function testGetType() |
|
45
|
|
|
{ |
|
46
|
|
|
global $LegacyFormHelperTest_legacySymfonyVersion; |
|
|
|
|
|
|
47
|
|
|
$formType = 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'; |
|
48
|
|
|
|
|
49
|
|
|
$LegacyFormHelperTest_legacySymfonyVersion = true; |
|
50
|
|
|
$this->assertEquals('choice', LegacyFormHelper::getType($formType)); |
|
51
|
|
|
|
|
52
|
|
|
$LegacyFormHelperTest_legacySymfonyVersion = false; |
|
53
|
|
|
$this->assertEquals($formType, LegacyFormHelper::getType($formType)); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
namespace Fresh\DoctrineEnumBundle\Util { |
|
59
|
|
|
|
|
60
|
|
|
function method_exists($class, $method) |
|
|
|
|
|
|
61
|
|
|
{ |
|
62
|
|
|
global $LegacyFormHelperTest_legacySymfonyVersion; |
|
|
|
|
|
|
63
|
|
|
return !$LegacyFormHelperTest_legacySymfonyVersion; |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
Instead of relying on
globalstate, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state