public function testMapObject() { $productName = $this->product->getName(); $productDescription = $this->product->getDescription(); $manufacturerName = $this->product->getManufacturer()->getName(); $allTextData = sprintf('%s %s %s', $productName, $productDescription, $manufacturerName); $productMapping = array('text' => array('name' => $productName, 'description' => $productDescription, 'manufacturer' => $manufacturerName, 'all_data' => $allTextData, Indexer::TEXT_ALL_DATA_FIELD => $allTextData), 'decimal' => array('price' => $this->product->getPrice()), 'integer' => array('count' => $this->product->getCount())); $this->assertEquals($productMapping, $this->mapper->mapObject($this->product)); $manufacturer = new Manufacturer(); $manufacturer->setName('reebok'); $manufacturer->addProduct($this->product); $manufacturerMapping = array('text' => array('products' => $productName, Indexer::TEXT_ALL_DATA_FIELD => $productName)); $this->assertEquals($manufacturerMapping, $this->mapper->mapObject($manufacturer)); }
public function testMapObjectForNullFieldsAndManyToOneRelation() { $product = new Product(); $product->setName('test product'); $expectedMapping = ['text' => ['name' => $product->getName(), 'all_data' => $product->getName(), Indexer::TEXT_ALL_DATA_FIELD => $product->getName()]]; $this->assertEquals($expectedMapping, $this->mapper->mapObject($product)); }