AccessibleObjectTest.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /*
  3. * This file is part of the PHP CS utility.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace Symfony\CS\Tests\Test;
  11. use Symfony\CS\Test\AccessibleObject;
  12. use Symfony\CS\Tests\Fixtures\Test\AccessibleObjectTest\DummyClass;
  13. /**
  14. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  15. *
  16. * @internal
  17. */
  18. final class AccessibleObjectTest extends \PHPUnit_Framework_TestCase
  19. {
  20. protected $accessibleObject;
  21. protected function setUp()
  22. {
  23. $this->accessibleObject = new AccessibleObject(new DummyClass());
  24. }
  25. public function testCreate()
  26. {
  27. $object = AccessibleObject::create(new \stdClass());
  28. $this->assertInstanceOf('Symfony\CS\Test\AccessibleObject', $object);
  29. }
  30. public function testGet()
  31. {
  32. $this->assertSame('publicVar_value', $this->accessibleObject->publicVar);
  33. $this->assertSame('privateVar_value', $this->accessibleObject->privateVar);
  34. }
  35. public function testSet()
  36. {
  37. $this->accessibleObject->publicVar = 'newValue1';
  38. $this->accessibleObject->privateVar = 'newValue2';
  39. $this->assertSame('newValue1', $this->accessibleObject->publicVar);
  40. $this->assertSame('newValue2', $this->accessibleObject->privateVar);
  41. }
  42. public function testIsset()
  43. {
  44. $this->assertTrue(isset($this->accessibleObject->publicVar));
  45. $this->assertTrue(isset($this->accessibleObject->privateVar));
  46. $this->assertFalse(isset($this->accessibleObject->nonExistingVar));
  47. }
  48. public function testCall()
  49. {
  50. $this->assertSame('publicMethod_result', $this->accessibleObject->publicMethod());
  51. $this->assertSame('privateMethod_result', $this->accessibleObject->privateMethod());
  52. }
  53. }