‪TYPO3CMS  9.5
PublicPropertyDeprecationTraitTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
20 
24 class ‪PublicPropertyDeprecationTraitTest extends UnitTestCase
25 {
30  protected ‪$fixture;
31 
38  protected function ‪setUp()
39  {
40  $this->fixture = new class {
42  private $deprecatedPublicProperties = [
43  'taggedProperty' => 'taggedProperty is deprecated',
44  'unsetTaggedProperty' => 'unsetTaggedProperty is deprecated'
45  ];
46 
47  public $publicProperty = 'publicProperty';
48 
49  public $unsetPublicProperty;
50 
54  protected $taggedProperty = 'taggedProperty';
55 
59  protected $unsetTaggedProperty;
60 
61  protected $untaggedProperty = 'untaggedProperty';
62  };
63  }
64 
68  public function ‪issetDataProvider(): array
69  {
70  return [
71  'public property' => [true, 'publicProperty'],
72  'unset public property' => [false, 'unsetPublicProperty'],
73  'tagged property' => [true, 'taggedProperty'],
74  'unset tagged property' => [false, 'unsetTaggedProperty'],
75  'untagged property' => [false, 'untaggedProperty'],
76  'unknown property' => [false, 'unknownProperty'],
77  ];
78  }
79 
86  public function ‪issetWorksAsExpected(bool $expected, string $property)
87  {
88  $this->assertSame($expected, isset($this->fixture->$property));
89  }
90 
95  {
96  // Uses __isset()
97  $this->assertFalse(isset($this->fixture->unknownProperty));
98  // Uses __set()
99  $this->fixture->unknownProperty = 23;
100  // Don't uses __isset()
101  $this->assertTrue(isset($this->fixture->unknownProperty));
102  // Don't uses __get()
103  $this->assertSame(23, $this->fixture->unknownProperty);
104  // Don't uses __unset()
105  unset($this->fixture->unknownProperty);
106  // Uses __isset()
107  $this->assertFalse(isset($this->fixture->unknownProperty));
108  }
109 
113  public function ‪publicPropertyCanBeHandledAsUsual()
114  {
115  $this->assertFalse(isset($this->fixture->unsetPublicProperty));
116  $this->fixture->unsetPublicProperty = 23;
117  $this->assertTrue(isset($this->fixture->unsetPublicProperty));
118  $this->assertSame(23, $this->fixture->unsetPublicProperty);
119  unset($this->fixture->unsetPublicProperty);
120  $this->assertFalse(isset($this->fixture->unsetPublicProperty));
121  }
122 
127  {
128  $this->assertFalse(isset($this->fixture->unsetTaggedProperty));
129  $this->fixture->unsetTaggedProperty = 23;
130  $this->assertTrue(isset($this->fixture->unsetTaggedProperty));
131  $this->assertSame(23, $this->fixture->unsetTaggedProperty);
132  unset($this->fixture->unsetTaggedProperty);
133  $this->assertFalse(isset($this->fixture->unsetTaggedProperty));
134  }
135 
139  public function ‪invalidPropertiesDataProvider(): array
140  {
141  return [
142  'untagged' => ['untaggedProperty'],
143  'unknown' => ['unknownProperty'],
144  ];
145  }
146 }
‪TYPO3\CMS\Core\Tests\Unit\Compatibility
Definition: PublicPropertyDeprecationTraitTest.php:3
‪TYPO3\CMS\Core\Tests\Unit\Compatibility\PublicPropertyDeprecationTraitTest\invalidPropertiesDataProvider
‪array invalidPropertiesDataProvider()
Definition: PublicPropertyDeprecationTraitTest.php:138
‪TYPO3\CMS\Core\Tests\Unit\Compatibility\PublicPropertyDeprecationTraitTest\$fixture
‪object $fixture
Definition: PublicPropertyDeprecationTraitTest.php:29
‪TYPO3\CMS\Core\Tests\Unit\Compatibility\PublicPropertyDeprecationTraitTest\unknownPropertyCanBeHandledAsUsual
‪unknownPropertyCanBeHandledAsUsual()
Definition: PublicPropertyDeprecationTraitTest.php:93
‪TYPO3\CMS\Core\Tests\Unit\Compatibility\PublicPropertyDeprecationTraitTest\publicPropertyCanBeHandledAsUsual
‪publicPropertyCanBeHandledAsUsual()
Definition: PublicPropertyDeprecationTraitTest.php:112
‪TYPO3\CMS\Core\Tests\Unit\Compatibility\PublicPropertyDeprecationTraitTest\taggedPropertyCanBeHandledLikePublicProperty
‪taggedPropertyCanBeHandledLikePublicProperty()
Definition: PublicPropertyDeprecationTraitTest.php:125
‪TYPO3\CMS\Core\Tests\Unit\Compatibility\PublicPropertyDeprecationTraitTest\issetDataProvider
‪array issetDataProvider()
Definition: PublicPropertyDeprecationTraitTest.php:67
‪TYPO3\CMS\Core\Tests\Unit\Compatibility\PublicPropertyDeprecationTraitTest\setUp
‪setUp()
Definition: PublicPropertyDeprecationTraitTest.php:37
‪TYPO3\CMS\Core\Tests\Unit\Compatibility\PublicPropertyDeprecationTraitTest
Definition: PublicPropertyDeprecationTraitTest.php:25
‪TYPO3\CMS\Core\Compatibility\PublicPropertyDeprecationTrait
Definition: PublicPropertyDeprecationTrait.php:66
‪TYPO3\CMS\Core\Tests\Unit\Compatibility\PublicPropertyDeprecationTraitTest\issetWorksAsExpected
‪issetWorksAsExpected(bool $expected, string $property)
Definition: PublicPropertyDeprecationTraitTest.php:85