Esempio n. 1
0
 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));
 }
Esempio n. 2
0
 /**
  * @param  string  $name
  * @return Product
  */
 protected function createTestEntity($name)
 {
     $result = new Product();
     $result->setName($name);
     return $result;
 }
Esempio n. 3
0
 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));
 }