public function testRenderTranslated() { $recipient = CMTest_TH::createUser(); $mail = new CM_Mail_Welcome($recipient); $language = CM_Model_Language::create('Test language', 'foo', true); $language->setTranslation('Welcome to {$siteName}!', 'foo'); list($subject, $html, $text) = $mail->render(); $nodeList = new CM_Dom_NodeList($html); $this->assertContains('foo', $nodeList->getText()); $nodeLink = $nodeList->find('a'); $this->assertSame(1, $nodeLink->count()); $this->assertSame('http://www.default.dev/example', $nodeLink->getAttribute('href')); $this->assertSame('Example Page', $nodeLink->getText()); $this->assertContains('border-style:solid;', $nodeLink->getAttribute('style')); }
/** * @param CM_Dom_NodeList $page * @param bool $warnings */ public static function assertTidy(CM_Dom_NodeList $page, $warnings = true) { if (!extension_loaded('tidy')) { self::markTestSkipped('The tidy extension is not available.'); } $html = $page->getHtml(); $tidy = new tidy(); $tidyConfig = array('show-errors' => 1, 'show-warnings' => $warnings); $tidy->parseString($html, $tidyConfig, 'UTF8'); //$tidy->cleanRepair(); $tidy->diagnose(); $lines = array_reverse(explode("\n", $tidy->errorBuffer)); $content = ''; foreach ($lines as $line) { if (empty($line) || $line == 'No warnings or errors were found.' || strpos($line, 'Info:') === 0 || strpos($line, 'errors were found!') > 0 || strpos($line, 'proprietary attribute') != false) { // ignore } else { $content .= $line . PHP_EOL; } } self::assertEmpty($content, $content); }
public function testLoadComponent() { $response = $this->getResponseAjax(new CM_Component_Graph(), 'loadComponent', ['className' => 'CM_Component_Graph', 'series' => []]); $this->assertViewResponseSuccess($response); $successContent = CM_Params::decode($response->getContent(), true)['success']; $autoId = $successContent['data']['autoId']; $this->assertNotEmpty($autoId); $html = new CM_Dom_NodeList($successContent['data']['html']); $this->assertSame($autoId, $html->getAttribute('id')); $this->assertArrayNotHasKey('exec', $successContent); $this->assertContains('new CM_Component_Graph', $successContent['data']['js']); }
public function testRender() { $html = new CM_Dom_NodeList(smarty_function_menu(['data' => $this->_menuData, 'activePage' => new CM_Page_Example(['foo' => 1])], $this->_template)); $this->assertContains('menu', $html->getAttribute('class')); $this->assertCount(2, $html->find('> li')); }
public function testFindDescendantChild() { $list = new CM_Dom_NodeList('<div class="foo"><div class="bar"></div></div>'); $this->assertTrue($list->has('.bar')); }
public function testRenderWithoutNamespace() { $html = new CM_Dom_NodeList(smarty_function_component(array('name' => '*_Component_Notfound'), $this->_template)); $this->assertContains('class="CM_Component_Notfound', $html->getHtml()); }