Example #1
0
 /**
  * Tests the setPriority() method.
  * @param int $expected The expected priority.
  * @param mixed $priority The priority to be set.
  * @covers \ManiaScript\Builder\Code::setPriority
  * @dataProvider provideSetPriority
  */
 public function testSetPriority($expected, $priority)
 {
     $code = new Code();
     $result = $code->setPriority($priority);
     $this->assertPropertyEquals($expected, $code, 'priority');
     $this->assertEquals($code, $result);
 }
 /**
  * Adds global code to the builder.
  * @param string $globalCode The global code.
  * @param int $priority The priority of the code. Defaults to PHP_INT_MAX to add the code to the end of the script.
  * @return $this Implementing fluent interface.
  */
 protected function addGlobalCode($globalCode, $priority = PHP_INT_MAX)
 {
     if (!empty($globalCode)) {
         $code = new Code();
         $code->setCode($globalCode)->setPriority($priority);
         $this->builder->addGlobalCode($code);
     }
     return $this;
 }
 /**
  * Provides the data for the addGlobalCode() test.
  * @return array The data.
  */
 public function provideAddGlobalCode()
 {
     $code = new Code();
     $code->setCode('abc')->setPriority(42);
     return array(array(null, '', 1337), array($code, 'abc', 42));
 }
Example #4
0
 /**
  * Adds code to the global scope of the ManiaLink.
  * @param string $code The code.
  * @param int $priority The priority, 0 for most important, bigger for less important.
  * @return $this Implementing fluent interface.
  */
 public function addGlobalCode($code, $priority = 5)
 {
     $globalCode = new Code();
     $globalCode->setCode($code)->setPriority($priority);
     $this->builder->addGlobalCode($globalCode);
     return $this;
 }