/** * @depends test_construct * @covers ::doAdvance */ public function test_doAdvance() { # Set up function. $Called = 0; $Arguments = array(); $this->Compiler->_on('Advance', function () use(&$Called, &$Arguments) { $Called++; $Arguments = func_get_args(); }); # Valid arguments $this->Compiler->doAdvance(-1); $this->assertEquals(1, $Called, 'Compiler::doAdvance() Failed to trigger callback'); $this->assertNotEmpty($Arguments, 'Compiler::doAdvance() Caused an exceptional behaviour'); $this->assertInstanceOf('\\BLW\\Type\\IEvent', $Arguments[0], 'Compiler::doAdvance() Created and invalid event'); $this->assertEquals(-1, $Arguments[0]->Steps, 'Compiler::doAdvance() Created and invalid event'); # Invalid arguments try { $this->Compiler->doAdvance(NULL); $this->fail('Failed to generate exception with invalid arguments'); } catch (InvalidArgumentException $e) { } # No mediator $this->Compiler->clearMediator(); $this->Compiler->doAdvance(-1); }