Exemplo n.º 1
0
 public function testSaveDeleteItem()
 {
     $params = (object) array('site' => 'unittest', 'limit' => 1);
     $textManager = new Controller_ExtJS_Text_Default(TestHelper::getContext());
     $result = $textManager->searchItems($params);
     $params = (object) array('site' => 'unittest', 'condition' => (object) array('&&' => array(0 => (object) array('==' => (object) array('text.list.type.domain' => 'text')))), 'start' => 0, 'limit' => 1);
     $textListTypeManager = Controller_ExtJS_Text_List_Type_Factory::createController(TestHelper::getContext());
     $resultType = $textListTypeManager->searchItems($params);
     $saveParams = (object) array('site' => 'unittest', 'items' => (object) array('text.list.parentid' => $result['items'][0]->{'text.id'}, 'text.list.typeid' => $resultType['items'][0]->{'text.list.type.id'}, 'text.list.domain' => 'text', 'text.list.refid' => 123, 'text.list.datestart' => '2000-01-01 00:00:00', 'text.list.dateend' => '2001-01-01 00:00:00', 'text.list.config' => array('test' => 'unit'), 'text.list.position' => 1, 'text.list.status' => 1));
     $searchParams = (object) array('site' => 'unittest', 'condition' => (object) array('&&' => array(0 => (object) array('==' => (object) array('text.list.refid' => 123)))));
     $saved = $this->_object->saveItems($saveParams);
     $searched = $this->_object->searchItems($searchParams);
     $deleteParams = (object) array('site' => 'unittest', 'items' => $saved['items']->{'text.list.id'});
     $this->_object->deleteItems($deleteParams);
     $result = $this->_object->searchItems($searchParams);
     $this->assertInternalType('object', $saved['items']);
     $this->assertNotNull($saved['items']->{'text.list.id'});
     $this->assertEquals($saved['items']->{'text.list.id'}, $searched['items'][0]->{'text.list.id'});
     $this->assertEquals($saved['items']->{'text.list.parentid'}, $searched['items'][0]->{'text.list.parentid'});
     $this->assertEquals($saved['items']->{'text.list.typeid'}, $searched['items'][0]->{'text.list.typeid'});
     $this->assertEquals($saved['items']->{'text.list.domain'}, $searched['items'][0]->{'text.list.domain'});
     $this->assertEquals($saved['items']->{'text.list.refid'}, $searched['items'][0]->{'text.list.refid'});
     $this->assertEquals($saved['items']->{'text.list.datestart'}, $searched['items'][0]->{'text.list.datestart'});
     $this->assertEquals($saved['items']->{'text.list.dateend'}, $searched['items'][0]->{'text.list.dateend'});
     $this->assertEquals($saved['items']->{'text.list.config'}, $searched['items'][0]->{'text.list.config'});
     $this->assertEquals($saved['items']->{'text.list.position'}, $searched['items'][0]->{'text.list.position'});
     $this->assertEquals($saved['items']->{'text.list.status'}, $searched['items'][0]->{'text.list.status'});
     $this->assertEquals(1, count($searched['items']));
     $this->assertEquals(0, count($result['items']));
 }
Exemplo n.º 2
0
 public function testSaveItemLabelContent()
 {
     $context = TestHelper::getContext();
     $methods = array('createItem', 'saveItem');
     $managerStub = $this->getMock('MShop_Text_Manager_Default', $methods, array($context));
     $itemStub = $this->getMock('MShop_Text_Item_Default');
     $managerStub->expects($this->once())->method('createItem')->will($this->returnValue($itemStub));
     $managerStub->expects($this->once())->method('saveItem');
     $itemStub->expects($this->once())->method('getContent')->will($this->returnValue("<br>\ntest<br>\n<br>\ncontent"));
     $itemStub->expects($this->once())->method('setContent')->with($this->equalTo("<br>\ntest<br>\n<br>\ncontent"));
     $itemStub->expects($this->once())->method('setLabel')->with($this->equalTo('test content'));
     MShop_Text_Manager_Factory::injectManager('MShop_Text_Manager_Default', $managerStub);
     $saveParams = (object) array('site' => 'unittest', 'items' => (object) array('text.content' => "<br>\ntest<br>\n<br>\ncontent<br>\n<br>\r\n"));
     $cntl = new Controller_ExtJS_Text_Default($context);
     $cntl->saveItems($saveParams);
     MShop_Text_Manager_Factory::injectManager('MShop_Text_Manager_Default', null);
 }