Ejemplo n.º 1
0
 /**
  * Test the `addOperator` and `getTernaryOperator` accessors for the `else` token.
  */
 public function testTernaryOperatorAccessorsForElseToken()
 {
     $operator = new TernaryOperator(1, 2, 10, TernaryOperator::RIGHT, true, function () {
     });
     $token = new Token($operator->getElseCode(), ':', 1);
     $table = new OperatorTable();
     $table->addOperator($operator);
     $this->assertSame($operator, $table->getTernaryOperator($token));
 }
Ejemplo n.º 2
0
 /**
  * Test all getters for the values set with the constructor.
  */
 public function testConstructorAccessors()
 {
     $ifCode = mt_rand(1, 100);
     $elseCode = mt_rand(1, 100);
     $precedence = mt_rand(1, 100);
     $allowShorthand = mt_rand(0, 1);
     $closure = function () {
     };
     $operator = new TernaryOperator($ifCode, $elseCode, $precedence, TernaryOperator::LEFT, $allowShorthand, $closure);
     $this->assertSame($ifCode, $operator->getIfCode());
     $this->assertSame($elseCode, $operator->getElseCode());
     $this->assertSame($precedence, $operator->getPrecedence());
     $this->assertSame($allowShorthand, $operator->isShorthandAllowed());
     $this->assertSame($closure, $operator->getNode());
 }