Beispiel #1
0
 /**
  * @dataProvider fileProvider
  */
 public function testYuml(BuilderInterface $builder, $fixture, $config)
 {
     $result = $builder->configure($config)->setPath($fixture)->build();
     $this->assertInternalType('array', $result);
     $this->assertGreaterThan(0, count($result));
     $b = new Browser();
     foreach ($result as $message) {
         $url = explode(' ', $message);
         $response = $b->get($url[1]);
         $contentType = null;
         switch ($url[0]) {
             case '<info>PNG</info>':
                 $contentType = 'image/png';
                 break;
             case '<info>PDF</info>':
                 $contentType = 'application/pdf';
                 break;
             case '<info>URL</info>':
                 $contentType = 'text/html; charset=utf-8';
                 break;
             case '<info>JSON</info>':
                 $contentType = 'application/json';
                 break;
             case '<info>SVG</info>':
                 $contentType = 'image/svg+xml';
                 break;
         }
         $this->assertEquals($contentType, $response->getHeader('Content-Type'));
     }
 }
 /**
  * @dataProvider fileProvider
  */
 public function testBuild(BuilderInterface $builder, $data, $fixture, $type, $config)
 {
     $result = $builder->configure($config)->setPath($data)->build();
     $expected = file_get_contents($fixture);
     $current = str_replace(['<question>', '<comment>', '<info>', '</comment>', '</question>', '</info>'], '', str_replace("\n\n", "\n", $result));
     $this->assertEquals($expected, $current);
 }
Beispiel #3
0
 /**
  * creates the builder configuration.
  *
  * @param \YumlPhp\Builder\BuilderInterface $builder
  * @param InputInterface                    $input
  *
  * @return array
  */
 protected function getBuilderConfig(BuilderInterface $builder, InputInterface $input)
 {
     //scruffy, nofunky, plain
     //dir: LR TB RL
     //scale: 180 120 100 80 60
     $style = $input->getOption('style') ?: 'plain;dir:TB;scale:80;';
     $type = $builder->getType();
     return ['url' => 'http://yuml.me/diagram/' . $style . '/' . $type . '/', 'debug' => $input->getOption('debug'), 'style' => $input->getOption('style') ?: 'plain;dir:LR;scale:80;'];
 }
 public function testRequest()
 {
     $response = $this->getMock('Buzz\\Message\\Response');
     $response->expects($this->atLeastOnce())->method('isSuccessful')->will($this->returnValue(true));
     $response->expects($this->atLeastOnce())->method('getContent')->will($this->returnValue('foo'));
     $this->browser->expects($this->atLeastOnce())->method('post')->will($this->returnValue($response));
     $result = $this->builder->configure(['url' => 'http://lolcathost', 'debug' => false])->setPath(sys_get_temp_dir())->build();
     $this->assertInternalType('array', $result);
     $this->assertGreaterThan(0, count($result));
     $this->assertEquals(['<info>PNG</info> http://yuml.me/foo', '<info>URL</info> http://yuml.me/edit/foo', '<info>PDF</info> http://yuml.me/foo', '<info>JSON</info> http://yuml.me/foo', '<info>SVG</info> http://yuml.me/foo'], $result);
 }