Ejemplo n.º 1
0
 public function testCmdBuffer()
 {
     $msg = 'AYB';
     $this->render3d->workingDir($this->workingDir);
     $this->render3d->filename('file.from');
     $converter = $this->getMock('\\Libre3d\\Render3d\\Convert\\Convert', ['convert'], [$this->render3d]);
     $converter->expects($this->any())->method('convert')->will($this->returnCallback(function () use($msg) {
         $this->render3d->cmd('echo ' . $msg);
     }));
     $this->render3d->registerConverter($converter, 'from', 'to');
     // starting out, buffer should be empty
     $this->assertEmpty($this->render3d->getBufferAndClean());
     // default should have buffer off, so message should just go away
     ob_start();
     $this->render3d->convertTo('to');
     $this->assertEmpty($this->render3d->getBufferAndClean());
     $this->assertEmpty(ob_get_clean());
     // it should echo out.  We'll catch it in our own buffer
     ob_start();
     $this->render3d->convertTo('to', ['buffer' => Render3d::BUFFER_STD_OUT]);
     $this->assertEmpty($this->render3d->getBufferAndClean());
     $this->assertSame($msg, trim(ob_get_clean()));
     // it should be caught in the buffer
     ob_start();
     $this->render3d->convertTo('to', ['buffer' => Render3d::BUFFER_ON]);
     $this->assertSame($msg, trim($this->render3d->getBufferAndClean()));
     $this->assertEmpty(ob_get_clean());
 }
Ejemplo n.º 2
0
 public function testConvertStr()
 {
     // Note: This convert is entirely "in PHP" so go ahead and test out the full process without stubbing out cmd()
     $render3d = new Render3d();
     $name = 'example';
     $render3d->workingDir($this->workingDir);
     $render3d->file($name);
     $render3d->fileType('stl');
     copy($this->testFilesDir . $name . '.stl', $this->workingDir . $name . '.stl');
     $converter = new StlPov($render3d);
     $currentDir = getcwd();
     chdir($this->workingDir);
     $converter->convert(true);
     chdir($currentDir);
     // Make sure it updated the file type when successful
     $this->assertEquals('pov', $render3d->fileType(), 'Ensure that the file type was updated when convert successful');
     $this->assertEquals($name, $render3d->file(), 'Ensure that the filename stayed the same for consistency');
     $this->assertFileExists($this->workingDir . $name . '.pov', 'Ensure that the pov file was created');
 }