‪TYPO3CMS  9.5
BooleanConverterTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
17 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
18 
22 class ‪BooleanConverterTest extends UnitTestCase
23 {
27  protected ‪$converter;
28 
29  protected function ‪setUp()
30  {
31  $this->converter = new \TYPO3\CMS\Extbase\Property\TypeConverter\BooleanConverter();
32  }
33 
37  public function ‪checkMetadata()
38  {
39  $this->assertEquals(['boolean', 'string'], $this->converter->getSupportedSourceTypes(), 'Source types do not match');
40  $this->assertEquals('boolean', $this->converter->getSupportedTargetType(), 'Target type does not match');
41  $this->assertEquals(10, $this->converter->getPriority(), 'Priority does not match');
42  }
43 
48  {
49  $source = true;
50  $this->assertEquals($source, $this->converter->convertFrom($source, 'boolean'));
51  }
52 
57  {
58  $source = 'true';
59  $this->assertTrue($this->converter->convertFrom($source, 'boolean'));
60  }
61 
66  {
67  $source = '1';
68  $this->assertTrue($this->converter->convertFrom($source, 'boolean'));
69  }
70 }
‪TYPO3\CMS\Extbase\Tests\Unit\Property\TypeConverter\BooleanConverterTest\$converter
‪TYPO3 CMS Extbase Property TypeConverter BooleanConverter $converter
Definition: BooleanConverterTest.php:26
‪TYPO3\CMS\Extbase\Tests\Unit\Property\TypeConverter
Definition: ArrayConverterTest.php:2
‪TYPO3\CMS\Extbase\Tests\Unit\Property\TypeConverter\BooleanConverterTest\convertFromDoesNotModifyTheBooleanSource
‪convertFromDoesNotModifyTheBooleanSource()
Definition: BooleanConverterTest.php:46
‪TYPO3\CMS\Extbase\Tests\Unit\Property\TypeConverter\BooleanConverterTest\convertFromCastsSourceStringToBoolean
‪convertFromCastsSourceStringToBoolean()
Definition: BooleanConverterTest.php:55
‪TYPO3\CMS\Extbase\Tests\Unit\Property\TypeConverter\BooleanConverterTest\setUp
‪setUp()
Definition: BooleanConverterTest.php:28
‪TYPO3\CMS\Extbase\Tests\Unit\Property\TypeConverter\BooleanConverterTest
Definition: BooleanConverterTest.php:23
‪TYPO3\CMS\Extbase\Tests\Unit\Property\TypeConverter\BooleanConverterTest\convertFromCastsNumericSourceStringToBoolean
‪convertFromCastsNumericSourceStringToBoolean()
Definition: BooleanConverterTest.php:64
‪TYPO3\CMS\Extbase\Tests\Unit\Property\TypeConverter\BooleanConverterTest\checkMetadata
‪checkMetadata()
Definition: BooleanConverterTest.php:36