Ejemplo n.º 1
0
 public function testCreatesLinkFromOtherComponentId()
 {
     $c = $this->_root->getComponentById(1005)->getComponent();
     $row = $c->getRow();
     $html = '<p><a href="1007-l1">foo</a></p>';
     $row->content = $html;
     $row->save();
     $m = Kwc_Basic_Text_Component::createChildModel($c->getData()->componentClass);
     $rows = $m->getRows($m->select()->whereEquals('component_id', '1005'));
     $this->assertEquals(1, count($rows));
     $row = $rows->current();
     $this->assertEquals('link', $row->component);
     $this->assertEquals('1', $row->nr);
     $m = Kwf_Model_Abstract::getInstance('Kwc_Basic_TextConvertLinkOnlyExtern_LinkExtern_TestModel');
     $rows = $m->getRows($m->select()->whereEquals('component_id', '1005-l1'));
     $this->assertEquals(1, count($rows));
     $row = $rows->current();
     $this->assertEquals('http://vivid.com', $row->target);
 }
Ejemplo n.º 2
0
 protected function _getModel()
 {
     return Kwc_Basic_Text_Component::createChildModel($this->_class);
 }
Ejemplo n.º 3
0
 public function testCreatesImageComponentx()
 {
     $uploadsModel = Kwf_Model_Abstract::getInstance('Kwc_Basic_Text_Image_UploadsModel');
     $upload1 = $uploadsModel->getRows()->current();
     $c = $this->_root->getComponentById(1008)->getComponent();
     $row = $c->getRow();
     $html = '<p><img src="http://www.vivid-planet.com/assets/web/images/structure/logo.png" /></p>';
     $html = $row->tidy($html);
     $this->assertRegExp("#^<p>\n  <img src=\"/kwf/kwctest/Kwc_Basic_Text_Root/media/Kwc_Basic_Text_Image_TestComponent/1008-i1/dh-100-[0-9a-z]+/[0-9a-z]+/[0-9]+/logo.png\" width=\"100\" height=\"100\" />\n</p>\$#ms", $html);
     $cc = array_values($c->getData()->getChildComponents());
     $this->assertEquals(1, count($cc));
     $this->assertEquals('1008-i1', current($cc)->componentId);
     $m = Kwc_Basic_Text_Component::createChildModel($c->getData()->componentClass);
     $rows = $m->getRows($m->select()->whereEquals('component_id', '1008'));
     $this->assertEquals(1, count($rows));
     $row = $rows->current();
     $this->assertEquals('image', $row->component);
     $this->assertEquals('1', $row->nr);
     $s = new Kwf_Model_Select();
     $s->whereNotEquals('id', $upload1->id);
     $upload2 = $uploadsModel->getRows($s)->current();
     $this->assertEquals('image/png', $upload2->mime_type);
     $this->assertEquals('png', $upload2->extension);
     $this->assertEquals('logo', $upload2->filename);
     $this->assertEquals(file_get_contents($upload2->getFileSource()), file_get_contents('http://www.vivid-planet.com/assets/web/images/structure/logo.png'));
     $m = Kwf_Model_Abstract::getInstance('Kwc_Basic_Text_Image_TestModel');
     $rows = $m->getRows($m->select()->whereEquals('component_id', '1008-i1'));
     $this->assertEquals(1, count($rows));
     $row = $rows->current();
     $this->assertEquals($upload2->id, $row->kwf_upload_id);
 }