Example #1
0
 public function testSaveDeleteItem()
 {
     $params = (object) array('site' => 'unittest', 'limit' => 1);
     $productManager = new \Aimeos\Controller\ExtJS\Product\Standard(\TestHelper::getContext());
     $result = $productManager->searchItems($params);
     $params = (object) array('site' => 'unittest', 'condition' => (object) array('&&' => array(0 => (object) array('==' => (object) array('product.lists.type.domain' => 'text')))), 'start' => 0, 'limit' => 1);
     $productListTypeManager = \Aimeos\Controller\ExtJS\Product\Lists\Type\Factory::createController(\TestHelper::getContext());
     $resultType = $productListTypeManager->searchItems($params);
     $saveParams = (object) array('site' => 'unittest', 'items' => (object) array('product.lists.parentid' => $result['items'][0]->{'product.id'}, 'product.lists.typeid' => $resultType['items'][0]->{'product.lists.type.id'}, 'product.lists.domain' => 'text', 'product.lists.refid' => -1, 'product.lists.datestart' => '2000-01-01 00:00:00', 'product.lists.dateend' => '2001-01-01 00:00:00', 'product.lists.config' => array('test' => 'unit'), 'product.lists.position' => 1, 'product.lists.status' => 1));
     $searchParams = (object) array('site' => 'unittest', 'condition' => (object) array('&&' => array(0 => (object) array('==' => (object) array('product.lists.refid' => -1)))));
     $saved = $this->object->saveItems($saveParams);
     $searched = $this->object->searchItems($searchParams);
     $deleteParams = (object) array('site' => 'unittest', 'items' => $saved['items']->{'product.lists.id'});
     $this->object->deleteItems($deleteParams);
     $result = $this->object->searchItems($searchParams);
     $this->assertInternalType('object', $saved['items']);
     $this->assertNotNull($saved['items']->{'product.lists.id'});
     $this->assertEquals($saved['items']->{'product.lists.id'}, $searched['items'][0]->{'product.lists.id'});
     $this->assertEquals($saved['items']->{'product.lists.parentid'}, $searched['items'][0]->{'product.lists.parentid'});
     $this->assertEquals($saved['items']->{'product.lists.typeid'}, $searched['items'][0]->{'product.lists.typeid'});
     $this->assertEquals($saved['items']->{'product.lists.domain'}, $searched['items'][0]->{'product.lists.domain'});
     $this->assertEquals($saved['items']->{'product.lists.refid'}, $searched['items'][0]->{'product.lists.refid'});
     $this->assertEquals($saved['items']->{'product.lists.datestart'}, $searched['items'][0]->{'product.lists.datestart'});
     $this->assertEquals($saved['items']->{'product.lists.dateend'}, $searched['items'][0]->{'product.lists.dateend'});
     $this->assertEquals($saved['items']->{'product.lists.config'}, $searched['items'][0]->{'product.lists.config'});
     $this->assertEquals($saved['items']->{'product.lists.position'}, $searched['items'][0]->{'product.lists.position'});
     $this->assertEquals($saved['items']->{'product.lists.status'}, $searched['items'][0]->{'product.lists.status'});
     $this->assertEquals(1, count($searched['items']));
     $this->assertEquals(0, count($result['items']));
 }
Example #2
0
 public function testSaveDeleteItem()
 {
     $searchParams = (object) array('site' => 'unittest', 'condition' => (object) array('&&' => array(0 => (object) array('==' => (object) array('product.code' => 'CNC')))));
     $prodCtrl = new \Aimeos\Controller\ExtJS\Product\Standard(\TestHelper::getContext());
     $products = $prodCtrl->searchItems($searchParams);
     $this->assertEquals(1, count($products['items']));
     $searchParams = (object) array('site' => 'unittest', 'condition' => (object) array('&&' => array(0 => (object) array('==' => (object) array('product.property.type.code' => 'package-weight')))));
     $typeCtrl = new \Aimeos\Controller\ExtJS\Product\Property\Type\Standard(\TestHelper::getContext());
     $types = $typeCtrl->searchItems($searchParams);
     $this->assertEquals(1, count($types['items']));
     $saveParams = (object) array('site' => 'unittest', 'items' => (object) array('product.property.parentid' => $products['items'][0]->{'product.id'}, 'product.property.typeid' => $types['items'][0]->{'product.property.type.id'}, 'product.property.languageid' => 'de', 'product.property.value' => 'unittest'));
     $searchParams = (object) array('site' => 'unittest', 'condition' => (object) array('&&' => array(0 => (object) array('==' => (object) array('product.property.value' => 'unittest')))));
     $saved = $this->object->saveItems($saveParams);
     $searched = $this->object->searchItems($searchParams);
     $deleteParams = (object) array('site' => 'unittest', 'items' => $saved['items']->{'product.property.id'});
     $this->object->deleteItems($deleteParams);
     $result = $this->object->searchItems($searchParams);
     $this->assertInternalType('object', $saved['items']);
     $this->assertNotNull($saved['items']->{'product.property.id'});
     $this->assertEquals($saved['items']->{'product.property.id'}, $searched['items'][0]->{'product.property.id'});
     $this->assertEquals($saved['items']->{'product.property.parentid'}, $searched['items'][0]->{'product.property.parentid'});
     $this->assertEquals($saved['items']->{'product.property.typeid'}, $searched['items'][0]->{'product.property.typeid'});
     $this->assertEquals($saved['items']->{'product.property.languageid'}, $searched['items'][0]->{'product.property.languageid'});
     $this->assertEquals($saved['items']->{'product.property.value'}, $searched['items'][0]->{'product.property.value'});
     $this->assertEquals(1, count($searched['items']));
     $this->assertEquals(0, count($result['items']));
 }