FOSSology  4.4.0
Open Source License Compliance by Open Source Software
ReflectoryTest.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2015 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
8 namespace Fossology\Lib\Test;
9 
11 {
12  private $internal = 1;
13  private function add($inc)
14  {
15  $this->internal += $inc;
16  return $this->internal;
17  }
18  public function getInternal()
19  {
20  return $this->internal;
21  }
22 }
23 
24 class ReflectoryTest extends \PHPUnit\Framework\TestCase
25 {
26  protected function setUp() : void
27  {
28  $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
29  }
30 
31  protected function tearDown() : void
32  {
33  $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore);
34  }
35 
36  public function testInvokeObjectsMethodnameWith()
37  {
38  $instanceWithPrivateMethod = new ClassWithPrivateMethod();
39  assertThat(Reflectory::invokeObjectsMethodnameWith($instanceWithPrivateMethod, 'add', array(2)),is(1+2));
40  assertThat(Reflectory::invokeObjectsMethodnameWith($instanceWithPrivateMethod, 'add', array(4)),is(1+2+4));
41  }
42 
43  public function testGetObjectsProperty()
44  {
45  $instanceWithPrivateMethod = new ClassWithPrivateMethod();
46  assertThat(Reflectory::getObjectsProperty($instanceWithPrivateMethod, 'internal'),is(1));
47  }
48 
49  public function testSetObjectsProperty()
50  {
51  $instanceWithPrivateMethod = new ClassWithPrivateMethod();
52  Reflectory::setObjectsProperty($instanceWithPrivateMethod, 'internal', 3);
53  assertThat($instanceWithPrivateMethod->getInternal(),is(3));
54  }
55 }
int Test
Definition: util.c:20