| Conditions | 1 |
| Paths | 1 |
| Total Lines | 48 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | public function testModifyReferencedVariables() |
||
| 11 | { |
||
| 12 | $context = $this->getContext(); |
||
| 13 | |||
| 14 | /** |
||
| 15 | * This variable is not needed for change |
||
| 16 | */ |
||
| 17 | $variableAValue = 1; |
||
| 18 | $variableAType = CompiledExpression::INTEGER; |
||
| 19 | $context->addVariable( |
||
| 20 | $variableA = new Variable('a', $variableAValue, $variableAType) |
||
| 21 | ); |
||
| 22 | |||
| 23 | /** |
||
| 24 | * $b = true; |
||
| 25 | */ |
||
| 26 | $context->addVariable( |
||
| 27 | $variableB = new Variable('b', true, CompiledExpression::BOOLEAN) |
||
| 28 | ); |
||
| 29 | |||
| 30 | /** |
||
| 31 | * $c = &$b; |
||
| 32 | */ |
||
| 33 | $variableC = new Variable('c'); |
||
| 34 | $variableC->setReferencedTo($variableB); |
||
| 35 | |||
| 36 | $context->addVariable( |
||
| 37 | $variableC |
||
| 38 | ); |
||
| 39 | |||
| 40 | $newType = CompiledExpression::INTEGER; |
||
| 41 | $newValue = 55; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * $b = {$newValue}; |
||
| 45 | * After it variable $c will change type and value |
||
| 46 | */ |
||
| 47 | $context->modifyReferencedVariables($variableB, $newType, $newValue); |
||
| 48 | |||
| 49 | self::assertSame($newValue, $variableC->getValue()); |
||
| 50 | self::assertSame($newType, $variableC->getType()); |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Assert that variable $a was not changed |
||
| 54 | */ |
||
| 55 | self::assertSame($variableAValue, $variableA->getValue()); |
||
| 56 | self::assertSame($variableAType, $variableA->getType()); |
||
| 57 | } |
||
| 58 | } |
||
| 59 |