Beispiel #1
0
    function test_extractItemFormats()
    {
        $layout = <<<'SVG'
<svg width="100.0" height="100.0" xmlns="http://www.w3.org/2000/svg">
  <g class="canvas">
    <!--SHAPE{"type":"s-tblock","id":"text_block1"}SHAPE-->
    <!--SHAPE{"type":"s-tblock","id":"text_block2"}SHAPE-->
    <!--SHAPE{"type":"s-list"}SHAPE-->
    <!--SHAPE{"type":"s-pageno","id":""}SHAPE-->
    <!--SHAPE{"type":"s-pageno","id":"page_no"}SHAPE-->
  </g>
</svg>
SVG;
        $formats = Layout::extractItemFormats($layout);
        $this->assertCount(4, $formats);
        $this->assertEquals(array('type' => 's-tblock', 'id' => 'text_block1'), $formats['text_block1']);
        $this->assertEquals(array('type' => 's-tblock', 'id' => 'text_block2'), $formats['text_block2']);
        $this->assertEquals(array('type' => 's-pageno', 'id' => 'page_no'), $formats['page_no']);
        $this->assertCount(1, preg_grep('/^__page_no_/', array_keys($formats)));
        $this->assertArrayNotHasKey('s-list', $formats);
    }