예제 #1
0
 public function testSpreadsheetModelBuilder()
 {
     $modelBuilder = new SpreadsheetModelBuilder();
     $cells = [];
     $cell1 = new \stdClass();
     $cell1->name = 'Foo';
     $inputSet11 = new \stdClass();
     $input111 = new \stdClass();
     $input111->value = 10;
     $input111->uncertainty = 0.15;
     $inputSet11->inputs = [$input111];
     $cell1->inputSets = [$inputSet11];
     $cells[] = $cell1;
     $cell2 = new \stdClass();
     $cell2->name = 'Bar';
     $cell2->inputSets = [];
     $cells[] = $cell2;
     $modelBuilder->bind('cells', $cells);
     /** @var Document $result */
     $result = $modelBuilder->build(new YamlMappingReader(__DIR__ . '/../Fixtures/mapping.yml'));
     $this->assertTrue($result instanceof Document);
     $this->assertCount(2, $result->getSheets());
     foreach ($result->getSheets() as $sheet) {
         $this->assertTrue($sheet instanceof Sheet);
     }
     $sheet = $result->getSheets()[0];
     $this->assertEquals('1 - Foo', $sheet->getLabel());
     $this->assertCount(1, $sheet->getTables());
     $table = $sheet->getTables()[0];
     $this->assertCount(1, $table->getLines());
     $this->assertCount(2, $table->getColumns());
     $this->assertCount(2, $table->getCells());
 }
예제 #2
0
 /**
  * @expectedException \Xport\Parser\ParsingException
  * @expectedExceptionMessage 'content' of type 'VerticalTable' must contains 'lines'
  */
 public function testTableWithoutLines()
 {
     $mapping = ['sheets' => [['content' => [['type' => 'VerticalTable', 'columns' => ['Col1', 'Col2']]]]]];
     $mappingReader = $this->getMockForAbstractClass('Xport\\MappingReader\\MappingReader');
     $mappingReader->expects($this->once())->method('getMapping')->will($this->returnValue($mapping));
     $modelBuilder = new SpreadsheetModelBuilder();
     $modelBuilder->build($mappingReader);
 }