public function testKeepCodeBufferOpen() { $shell = new Shell($this->getConfig()); $shell->addCode('1 \\'); $this->assertNull($shell->flushCode()); $this->assertTrue($shell->hasCode()); $shell->addCode('+ 1 \\'); $this->assertNull($shell->flushCode()); $this->assertTrue($shell->hasCode()); $shell->addCode('+ 1'); $code = $shell->flushCode(); $this->assertFalse($shell->hasCode()); $code = preg_replace('/\\s+/', ' ', $code); $this->assertNotNull($code); $this->assertEquals('return 1 + 1 + 1;', $code); }
public function testCodeBuffer() { $shell = new Shell(); $shell->addCode('class'); $this->assertNull($shell->flushCode()); $this->assertTrue($shell->hasCode()); $shell->addCode('a'); $this->assertNull($shell->flushCode()); $this->assertTrue($shell->hasCode()); $shell->addCode('{}'); $code = $shell->flushCode(); $this->assertFalse($shell->hasCode()); $code = preg_replace('/\\s+/', ' ', $code); $this->assertNotNull($code); $this->assertEquals('class a { }', $code); }