/** * @inheritdoc */ public function getQuotations($isNormalizingEnabled = false) { $quotations = array(); // Look for first available row $cellFound = false; $firstCellRowIndex = 1; while ($firstCellRowIndex <= self::MAX_FIRST_CELL_ROW && !$cellFound && $firstCellRowIndex <= $this->_reader->rowcount()) { if (intval($this->_reader->val($firstCellRowIndex, 1))) { $cellFound = true; break; } $firstCellRowIndex++; } if ($cellFound) { for ($i = $firstCellRowIndex; $i <= $this->_reader->rowcount(); $i++) { $config = array(); foreach ($this->getFields() as $index => $field) { $config[$field] = $this->_reader->val($i, $index + 1); } $quotation = new Quotation($config); $quotationToArray = $quotation->toArray($this->getFields()); $quotations[$quotation->getCode()] = $isNormalizingEnabled ? $this->_normalizer->normalize($quotationToArray) : $quotationToArray; } } return $quotations; }
/** * @dataProvider goodQuotationConfigs * @param Array $config * @param Array $result */ public function testToArray($config, $result) { $quotation = new Quotation($config); $quotationToArray = $quotation->toArray($config['fields']); $this->assertInternalType('array', $quotationToArray); $this->assertEquals(count($config['fields']), count($quotationToArray)); $this->assertEquals($result['toArray'], $quotationToArray); }