Пример #1
0
 /**
  * Tests the following features:
  * * different types of scalar fields
  * * scalar field without 'target_fields' mappings
  * * mapping to several target fields
  * * many-to-one relation
  */
 public function testMapObjectForProduct()
 {
     $productName = $this->product->getName();
     $productDescription = $this->product->getDescription();
     $manufacturerName = $this->product->getManufacturer()->getName();
     $allTextData = sprintf('%s %s %s', $productName, $productDescription, $manufacturerName);
     $expectedMapping = ['text' => ['name' => $productName, 'description' => $productDescription, 'manufacturer' => $manufacturerName, 'all_data' => $allTextData, Indexer::TEXT_ALL_DATA_FIELD => $allTextData], 'decimal' => ['price' => $this->product->getPrice()], 'integer' => ['count' => $this->product->getCount()]];
     $this->assertEquals($expectedMapping, $this->mapper->mapObject($this->product));
 }
Пример #2
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));
 }