{ // 获取包含Hugging Face文本的span元素 const spans = link.querySelectorAll('span.whitespace-nowrap, span.hidden.whitespace-nowrap'); spans.forEach(span => { if (span.textContent && span.textContent.trim().match(/Hugging\s*Face/i)) { span.textContent = 'AI快站'; } }); }); // 替换logo图片的alt属性 document.querySelectorAll('img[alt*="Hugging"], img[alt*="Face"]').forEach(img => { if (img.alt.match(/Hugging\s*Face/i)) { img.alt = 'AI快站 logo'; } }); } // 替换导航栏中的链接 function replaceNavigationLinks() { // 已替换标记,防止重复运行 if (window._navLinksReplaced) { return; } // 已经替换过的链接集合,防止重复替换 const replacedLinks = new Set(); // 只在导航栏区域查找和替换链接 const headerArea = document.querySelector('header') || document.querySelector('nav'); if (!headerArea) { return; } // 在导航区域内查找链接 const navLinks = headerArea.querySelectorAll('a'); navLinks.forEach(link => { // 如果已经替换过,跳过 if (replacedLinks.has(link)) return; const linkText = link.textContent.trim(); const linkHref = link.getAttribute('href') || ''; // 替换Spaces链接 - 仅替换一次 if ( (linkHref.includes('/spaces') || linkHref === '/spaces' || linkText === 'Spaces' || linkText.match(/^s*Spacess*$/i)) && linkText !== 'OCR模型免费转Markdown' && linkText !== 'OCR模型免费转Markdown' ) { link.textContent = 'OCR模型免费转Markdown'; link.href = 'https://fast360.xyz'; link.setAttribute('target', '_blank'); link.setAttribute('rel', 'noopener noreferrer'); replacedLinks.add(link); } // 删除Posts链接 else if ( (linkHref.includes('/posts') || linkHref === '/posts' || linkText === 'Posts' || linkText.match(/^s*Postss*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } // 替换Docs链接 - 仅替换一次 else if ( (linkHref.includes('/docs') || linkHref === '/docs' || linkText === 'Docs' || linkText.match(/^s*Docss*$/i)) && linkText !== '模型下载攻略' ) { link.textContent = '模型下载攻略'; link.href = '/'; replacedLinks.add(link); } // 删除Enterprise链接 else if ( (linkHref.includes('/enterprise') || linkHref === '/enterprise' || linkText === 'Enterprise' || linkText.match(/^s*Enterprises*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } }); // 查找可能嵌套的Spaces和Posts文本 const textNodes = []; function findTextNodes(element) { if (element.nodeType === Node.TEXT_NODE) { const text = element.textContent.trim(); if (text === 'Spaces' || text === 'Posts' || text === 'Enterprise') { textNodes.push(element); } } else { for (const child of element.childNodes) { findTextNodes(child); } } } // 只在导航区域内查找文本节点 findTextNodes(headerArea); // 替换找到的文本节点 textNodes.forEach(node => { const text = node.textContent.trim(); if (text === 'Spaces') { node.textContent = node.textContent.replace(/Spaces/g, 'OCR模型免费转Markdown'); } else if (text === 'Posts') { // 删除Posts文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } else if (text === 'Enterprise') { // 删除Enterprise文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } }); // 标记已替换完成 window._navLinksReplaced = true; } // 替换代码区域中的域名 function replaceCodeDomains() { // 特别处理span.hljs-string和span.njs-string元素 document.querySelectorAll('span.hljs-string, span.njs-string, span[class*="hljs-string"], span[class*="njs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换hljs-string类的span中的域名(移除多余的转义符号) document.querySelectorAll('span.hljs-string, span[class*="hljs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换pre和code标签中包含git clone命令的域名 document.querySelectorAll('pre, code').forEach(element => { if (element.textContent && element.textContent.includes('git clone')) { const text = element.innerHTML; if (text.includes('huggingface.co')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 处理特定的命令行示例 document.querySelectorAll('pre, code').forEach(element => { const text = element.innerHTML; if (text.includes('huggingface.co')) { // 针对git clone命令的专门处理 if (text.includes('git clone') || text.includes('GIT_LFS_SKIP_SMUDGE=1')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 特别处理模型下载页面上的代码片段 document.querySelectorAll('.flex.border-t, .svelte_hydrator, .inline-block').forEach(container => { const content = container.innerHTML; if (content && content.includes('huggingface.co')) { container.innerHTML = content.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 特别处理模型仓库克隆对话框中的代码片段 try { // 查找包含"Clone this model repository"标题的对话框 const cloneDialog = document.querySelector('.svelte_hydration_boundary, [data-target="MainHeader"]'); if (cloneDialog) { // 查找对话框中所有的代码片段和命令示例 const codeElements = cloneDialog.querySelectorAll('pre, code, span'); codeElements.forEach(element => { if (element.textContent && element.textContent.includes('huggingface.co')) { if (element.innerHTML.includes('huggingface.co')) { element.innerHTML = element.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { element.textContent = element.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); } // 更精确地定位克隆命令中的域名 document.querySelectorAll('[data-target]').forEach(container => { const codeBlocks = container.querySelectorAll('pre, code, span.hljs-string'); codeBlocks.forEach(block => { if (block.textContent && block.textContent.includes('huggingface.co')) { if (block.innerHTML.includes('huggingface.co')) { block.innerHTML = block.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { block.textContent = block.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); }); } catch (e) { // 错误处理但不打印日志 } } // 当DOM加载完成后执行替换 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); }); } else { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); } // 增加一个MutationObserver来处理可能的动态元素加载 const observer = new MutationObserver(mutations => { // 检查是否导航区域有变化 const hasNavChanges = mutations.some(mutation => { // 检查是否存在header或nav元素变化 return Array.from(mutation.addedNodes).some(node => { if (node.nodeType === Node.ELEMENT_NODE) { // 检查是否是导航元素或其子元素 if (node.tagName === 'HEADER' || node.tagName === 'NAV' || node.querySelector('header, nav')) { return true; } // 检查是否在导航元素内部 let parent = node.parentElement; while (parent) { if (parent.tagName === 'HEADER' || parent.tagName === 'NAV') { return true; } parent = parent.parentElement; } } return false; }); }); // 只在导航区域有变化时执行替换 if (hasNavChanges) { // 重置替换状态,允许再次替换 window._navLinksReplaced = false; replaceHeaderBranding(); replaceNavigationLinks(); } }); // 开始观察document.body的变化,包括子节点 if (document.body) { observer.observe(document.body, { childList: true, subtree: true }); } else { document.addEventListener('DOMContentLoaded', () => { observer.observe(document.body, { childList: true, subtree: true }); }); } })(); \n\nHTMLBLOC;\n\n\t\t$this->Controller->EmailTest->sendAs = 'text';\n\t\t$expect = '
' . str_replace('{CONTENTTYPE}', 'text/plain; charset=UTF-8', $header) . $text . \"\\n\" . '
';\n\t\t$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));\n\t\t$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));\n\n\t\t$this->Controller->EmailTest->sendAs = 'html';\n\t\t$expect = '
' . str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $header) . $html . \"\\n\" . '
';\n\t\t$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));\n\t\t$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));\n\n\t\t$this->Controller->EmailTest->sendAs = 'both';\n\t\t$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));\n\t\t$boundary = $this->Controller->EmailTest->getBoundary();\n\n\t\t$expect = str_replace('{CONTENTTYPE}', 'multipart/alternative; boundary=\"alt-' . $boundary . '\"', $header);\n\t\t$expect .= '--alt-' . $boundary . \"\\n\" . 'Content-Type: text/plain; charset=UTF-8' . \"\\n\" . 'Content-Transfer-Encoding: 7bit' . \"\\n\\n\" . $text . \"\\n\\n\";\n\t\t$expect .= '--alt-' . $boundary . \"\\n\" . 'Content-Type: text/html; charset=UTF-8' . \"\\n\" . 'Content-Transfer-Encoding: 7bit' . \"\\n\\n\" . $html . \"\\n\\n\";\n\t\t$expect = '
' . $expect . \"--alt-$boundary--\" . \"\\n\\n\" . '
';\n\t\t$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));\n\n\t\t$this->Controller->EmailTest->reset();\n\t\t$this->Controller->EmailTest->to = 'postmaster@localhost';\n\t\t$this->Controller->EmailTest->from = 'noreply@example.com';\n\t\t$this->Controller->EmailTest->subject = 'Cake SMTP test';\n\t\t$this->Controller->EmailTest->replyTo = 'noreply@example.com';\n\n\t\t$this->Controller->EmailTest->delivery = 'debug';\n\t\t$this->Controller->EmailTest->messageId = false;\n\n\t\t$html = <<\n\n\n\n\tEmail Test\n\n\n\n\t

This is the body of the message

\n\t

This email was sent using the CakePHP Framework

\n\n\n\nHTMLBLOC;\n\n\t\t$this->Controller->EmailTest->sendAs = 'html';\n\t\t$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message', 'default', 'thin'));\n\n\t\t$boundary = $this->Controller->EmailTest->getBoundary();\n\t\t$expect = str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $header) . $html;\n\t\t$expect = '
' . $expect . '
';\n\t\t$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));\n\t\t\n\t\t$result = ClassRegistry::getObject('view');\n\t\t$this->assertFalse($result);\n\t}"},"docstring":{"kind":"string","value":"testTemplates method\n\n@access public\n@return void"},"func_name":{"kind":"string","value":"testTemplates"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/email.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903663,"cells":{"code":{"kind":"string","value":"function testTemplateNestedElements() {\n\t\t$this->Controller->EmailTest->to = 'postmaster@localhost';\n\t\t$this->Controller->EmailTest->from = 'noreply@example.com';\n\t\t$this->Controller->EmailTest->subject = 'Cake SMTP test';\n\t\t$this->Controller->EmailTest->replyTo = 'noreply@example.com';\n\n\t\t$this->Controller->EmailTest->delivery = 'debug';\n\t\t$this->Controller->EmailTest->messageId = false;\n\t\t$this->Controller->EmailTest->layout = 'default';\n\t\t$this->Controller->EmailTest->template = 'nested_element';\n\t\t$this->Controller->EmailTest->sendAs = 'html';\n\t\t$this->Controller->helpers = array('Html');\n\n\t\t$this->Controller->EmailTest->send();\n\t\t$result = $this->Controller->Session->read('Message.email.message');\n\t\t$this->assertPattern('/Test/', $result);\n\t\t$this->assertPattern('/http\\:\\/\\/example\\.com/', $result);\n\t}"},"docstring":{"kind":"string","value":"test that elements used in email templates get helpers.\n\n@return void"},"func_name":{"kind":"string","value":"testTemplateNestedElements"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/email.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903664,"cells":{"code":{"kind":"string","value":"function testSmtpSendSocket() {\n\t\tif ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) {\n\t\t\treturn;\n\t\t}\n\n\t\t$this->Controller->EmailTest->smtpOptions['timeout'] = 10;\n\t\t$socket =& new CakeSocket(array_merge(array('protocol'=>'smtp'), $this->Controller->EmailTest->smtpOptions));\n\t\t$this->Controller->EmailTest->setConnectionSocket($socket);\n\n\t\t$this->assertTrue($this->Controller->EmailTest->getConnectionSocket());\n\n\t\t$response = $this->Controller->EmailTest->smtpSend('HELO', '250');\n\t\t$this->assertPattern('/501 Syntax: HELO hostname/', $this->Controller->EmailTest->smtpError);\n\n\t\t$this->Controller->EmailTest->reset();\n\t\t$response = $this->Controller->EmailTest->smtpSend('HELO somehostname', '250');\n\t\t$this->assertNoPattern('/501 Syntax: HELO hostname/', $this->Controller->EmailTest->smtpError);\n\t}"},"docstring":{"kind":"string","value":"testSmtpSendSocket method\n\n@access public\n@return void"},"func_name":{"kind":"string","value":"testSmtpSendSocket"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/email.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903665,"cells":{"code":{"kind":"string","value":"function testSendDebug() {\n\t\t$this->Controller->EmailTest->to = 'postmaster@localhost';\n\t\t$this->Controller->EmailTest->from = 'noreply@example.com';\n\t\t$this->Controller->EmailTest->cc = 'cc@example.com';\n\t\t$this->Controller->EmailTest->bcc = 'bcc@example.com';\n\t\t$this->Controller->EmailTest->subject = 'Cake Debug Test';\n\t\t$this->Controller->EmailTest->replyTo = 'noreply@example.com';\n\t\t$this->Controller->EmailTest->template = null;\n\n\t\t$this->Controller->EmailTest->delivery = 'debug';\n\t\t$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));\n\t\t$result = $this->Controller->Session->read('Message.email.message');\n\n\t\t$this->assertPattern('/To: postmaster@localhost\\n/', $result);\n\t\t$this->assertPattern('/Subject: Cake Debug Test\\n/', $result);\n\t\t$this->assertPattern('/Reply-To: noreply@example.com\\n/', $result);\n\t\t$this->assertPattern('/From: noreply@example.com\\n/', $result);\n\t\t$this->assertPattern('/Cc: cc@example.com\\n/', $result);\n\t\t$this->assertPattern('/Bcc: bcc@example.com\\n/', $result);\n\t\t$this->assertPattern('/Date: ' . preg_quote(date(DATE_RFC2822)) . '\\n/', $result);\n\t\t$this->assertPattern('/X-Mailer: CakePHP Email Component\\n/', $result);\n\t\t$this->assertPattern('/Content-Type: text\\/plain; charset=UTF-8\\n/', $result);\n\t\t$this->assertPattern('/Content-Transfer-Encoding: 7bitParameters:\\n/', $result);\n\t\t$this->assertPattern('/This is the body of the message/', $result);\n\t}"},"docstring":{"kind":"string","value":"testSendDebug method\n\n@access public\n@return void"},"func_name":{"kind":"string","value":"testSendDebug"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/email.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903666,"cells":{"code":{"kind":"string","value":"function testSendDebugWithNoSessions() {\n\t\t$session =& $this->Controller->Session;\n\t\tunset($this->Controller->Session);\n\t\t$this->Controller->EmailTest->to = 'postmaster@localhost';\n\t\t$this->Controller->EmailTest->from = 'noreply@example.com';\n\t\t$this->Controller->EmailTest->subject = 'Cake Debug Test';\n\t\t$this->Controller->EmailTest->replyTo = 'noreply@example.com';\n\t\t$this->Controller->EmailTest->template = null;\n\n\t\t$this->Controller->EmailTest->delivery = 'debug';\n\t\t$result = $this->Controller->EmailTest->send('This is the body of the message');\n\n\t\t$this->assertPattern('/To: postmaster@localhost\\n/', $result);\n\t\t$this->assertPattern('/Subject: Cake Debug Test\\n/', $result);\n\t\t$this->assertPattern('/Reply-To: noreply@example.com\\n/', $result);\n\t\t$this->assertPattern('/From: noreply@example.com\\n/', $result);\n\t\t$this->assertPattern('/Date: ' . preg_quote(date(DATE_RFC2822)) . '\\n/', $result);\n\t\t$this->assertPattern('/X-Mailer: CakePHP Email Component\\n/', $result);\n\t\t$this->assertPattern('/Content-Type: text\\/plain; charset=UTF-8\\n/', $result);\n\t\t$this->assertPattern('/Content-Transfer-Encoding: 7bitParameters:\\n/', $result);\n\t\t$this->assertPattern('/This is the body of the message/', $result);\n\t\t$this->Controller->Session = $session;\n\t}"},"docstring":{"kind":"string","value":"test send with delivery = debug and not using sessions.\n\n@return void"},"func_name":{"kind":"string","value":"testSendDebugWithNoSessions"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/email.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903667,"cells":{"code":{"kind":"string","value":"function testMessageRetrievalWithoutTemplate() {\n\t\tApp::build(array(\n\t\t\t'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)\n\t\t));\n\n\t\t$this->Controller->EmailTest->to = 'postmaster@localhost';\n\t\t$this->Controller->EmailTest->from = 'noreply@example.com';\n\t\t$this->Controller->EmailTest->subject = 'Cake Debug Test';\n\t\t$this->Controller->EmailTest->replyTo = 'noreply@example.com';\n\t\t$this->Controller->EmailTest->layout = 'default';\n\t\t$this->Controller->EmailTest->template = null;\n\n\t\t$this->Controller->EmailTest->delivery = 'debug';\n\n\t\t$text = $html = 'This is the body of the message';\n\n\t\t$this->Controller->EmailTest->sendAs = 'both';\n\t\t$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));\n\t\t$this->assertEqual($this->Controller->EmailTest->textMessage, $this->__osFix($text));\n\t\t$this->assertEqual($this->Controller->EmailTest->htmlMessage, $this->__osFix($html));\n\n\t\t$this->Controller->EmailTest->sendAs = 'text';\n\t\t$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));\n\t\t$this->assertEqual($this->Controller->EmailTest->textMessage, $this->__osFix($text));\n\t\t$this->assertNull($this->Controller->EmailTest->htmlMessage);\n\n\t\t$this->Controller->EmailTest->sendAs = 'html';\n\t\t$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));\n\t\t$this->assertNull($this->Controller->EmailTest->textMessage);\n\t\t$this->assertEqual($this->Controller->EmailTest->htmlMessage, $this->__osFix($html));\n\t}"},"docstring":{"kind":"string","value":"testMessageRetrievalWithoutTemplate method\n\n@access public\n@return void"},"func_name":{"kind":"string","value":"testMessageRetrievalWithoutTemplate"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/email.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903668,"cells":{"code":{"kind":"string","value":"function testMessageRetrievalWithTemplate() {\n\t\tApp::build(array(\n\t\t\t'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)\n\t\t));\n\n\t\t$this->Controller->set('value', 22091985);\n\t\t$this->Controller->set('title_for_layout', 'EmailTest');\n\n\t\t$this->Controller->EmailTest->to = 'postmaster@localhost';\n\t\t$this->Controller->EmailTest->from = 'noreply@example.com';\n\t\t$this->Controller->EmailTest->subject = 'Cake Debug Test';\n\t\t$this->Controller->EmailTest->replyTo = 'noreply@example.com';\n\t\t$this->Controller->EmailTest->layout = 'default';\n\t\t$this->Controller->EmailTest->template = 'custom';\n\n\t\t$this->Controller->EmailTest->delivery = 'debug';\n\n\t\t$text = <<\n\n\n\n\tEmailTest\n\n\n\n\t

Here is your value: 22091985

\n\t

This email was sent using the CakePHP Framework

\n\n\nHTMLBLOC;\n\n\t\t$this->Controller->EmailTest->sendAs = 'both';\n\t\t$this->assertTrue($this->Controller->EmailTest->send());\n\t\t$this->assertEqual($this->Controller->EmailTest->textMessage, $this->__osFix($text));\n\t\t$this->assertEqual($this->Controller->EmailTest->htmlMessage, $this->__osFix($html));\n\n\t\t$this->Controller->EmailTest->sendAs = 'text';\n\t\t$this->assertTrue($this->Controller->EmailTest->send());\n\t\t$this->assertEqual($this->Controller->EmailTest->textMessage, $this->__osFix($text));\n\t\t$this->assertNull($this->Controller->EmailTest->htmlMessage);\n\n\t\t$this->Controller->EmailTest->sendAs = 'html';\n\t\t$this->assertTrue($this->Controller->EmailTest->send());\n\t\t$this->assertNull($this->Controller->EmailTest->textMessage);\n\t\t$this->assertEqual($this->Controller->EmailTest->htmlMessage, $this->__osFix($html));\n\t}"},"docstring":{"kind":"string","value":"testMessageRetrievalWithTemplate method\n\n@access public\n@return void"},"func_name":{"kind":"string","value":"testMessageRetrievalWithTemplate"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/email.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903669,"cells":{"code":{"kind":"string","value":"function testSendContentArray() {\n\t\t$this->Controller->EmailTest->to = 'postmaster@localhost';\n\t\t$this->Controller->EmailTest->from = 'noreply@example.com';\n\t\t$this->Controller->EmailTest->subject = 'Cake Debug Test';\n\t\t$this->Controller->EmailTest->replyTo = 'noreply@example.com';\n\t\t$this->Controller->EmailTest->template = null;\n\t\t$this->Controller->EmailTest->delivery = 'debug';\n\n\t\t$content = array('First line', 'Second line', 'Third line');\n\t\t$this->assertTrue($this->Controller->EmailTest->send($content));\n\t\t$result = $this->Controller->Session->read('Message.email.message');\n\n\t\t$this->assertPattern('/To: postmaster@localhost\\n/', $result);\n\t\t$this->assertPattern('/Subject: Cake Debug Test\\n/', $result);\n\t\t$this->assertPattern('/Reply-To: noreply@example.com\\n/', $result);\n\t\t$this->assertPattern('/From: noreply@example.com\\n/', $result);\n\t\t$this->assertPattern('/X-Mailer: CakePHP Email Component\\n/', $result);\n\t\t$this->assertPattern('/Content-Type: text\\/plain; charset=UTF-8\\n/', $result);\n\t\t$this->assertPattern('/Content-Transfer-Encoding: 7bitParameters:\\n/', $result);\n\t\t$this->assertPattern('/First line\\n/', $result);\n\t\t$this->assertPattern('/Second line\\n/', $result);\n\t\t$this->assertPattern('/Third line\\n/', $result);\n\t}"},"docstring":{"kind":"string","value":"testContentArray method\n\n@access public\n@return void"},"func_name":{"kind":"string","value":"testSendContentArray"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/email.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903670,"cells":{"code":{"kind":"string","value":"function testDateProperty() {\n\t\t$this->Controller->EmailTest->to = 'postmaster@localhost';\n\t\t$this->Controller->EmailTest->from = 'noreply@example.com';\n\t\t$this->Controller->EmailTest->subject = 'Cake Debug Test';\n\t\t$this->Controller->EmailTest->date = 'Today!';\n\t\t$this->Controller->EmailTest->template = null;\n\t\t$this->Controller->EmailTest->delivery = 'debug';\n\n\t\t$this->assertTrue($this->Controller->EmailTest->send('test message'));\n\t\t$result = $this->Controller->Session->read('Message.email.message');\n\t\t$this->assertPattern('/Date: Today!\\n/', $result);\n\t}"},"docstring":{"kind":"string","value":"test setting a custom date.\n\n@return void"},"func_name":{"kind":"string","value":"testDateProperty"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/email.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903671,"cells":{"code":{"kind":"string","value":"function testContentStripping() {\n\t\t$content = \"Previous content\\n--alt-\\nContent-TypeContent-Type:: text/html; charsetcharset==utf-8\\nContent-Transfer-Encoding: 7bit\";\n\t\t$content .= \"\\n\\n

My own html content

\";\n\n\t\t$result = $this->Controller->EmailTest->strip($content, true);\n\t\t$expected = \"Previous content\\n--alt-\\n text/html; utf-8\\n 7bit\\n\\n

My own html content

\";\n\t\t$this->assertEqual($result, $expected);\n\n\t\t$content = '

Some HTML content with an email link';\n\t\t$result = $this->Controller->EmailTest->strip($content, true);\n\t\t$expected = $content;\n\t\t$this->assertEqual($result, $expected);\n\n\t\t$content = '

Some HTML content with an ';\n\t\t$content .= 'email link';\n\t\t$result = $this->Controller->EmailTest->strip($content, true);\n\t\t$expected = $content;\n\t\t$this->assertEqual($result, $expected);\n\n\t\t$content = 'This is a test email to: you and whomever you forward it to';\n\t\t$result = $this->Controller->EmailTest->strip($content, true);\n\t\t$expected = $content;\n\t\t$this->assertEqual($result, $expected);\n\t}"},"docstring":{"kind":"string","value":"testContentStripping method\n\n@access public\n@return void"},"func_name":{"kind":"string","value":"testContentStripping"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/email.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903672,"cells":{"code":{"kind":"string","value":"function testSendWithAttachments() {\n\t\t$this->Controller->EmailTest->to = 'postmaster@localhost';\n\t\t$this->Controller->EmailTest->from = 'noreply@example.com';\n\t\t$this->Controller->EmailTest->subject = 'Attachment Test';\n\t\t$this->Controller->EmailTest->replyTo = 'noreply@example.com';\n\t\t$this->Controller->EmailTest->template = null;\n\t\t$this->Controller->EmailTest->delivery = 'debug';\n\t\t$this->Controller->EmailTest->attachments = array(\n\t\t\t__FILE__,\n\t\t\t'some-name.php' => __FILE__\n\t\t);\n\t\t$body = '

This is the body of the message

';\n\n\t\t$this->Controller->EmailTest->sendAs = 'text';\n\t\t$this->assertTrue($this->Controller->EmailTest->send($body));\n\t\t$msg = $this->Controller->Session->read('Message.email.message');\n\t\t$this->assertPattern('/' . preg_quote('Content-Disposition: attachment; filename=\"email.test.php\"') . '/', $msg);\n\t\t$this->assertPattern('/' . preg_quote('Content-Disposition: attachment; filename=\"some-name.php\"') . '/', $msg);\n\t}"},"docstring":{"kind":"string","value":"undocumented function\n\n@return void\n@access public"},"func_name":{"kind":"string","value":"testSendWithAttachments"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/email.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903673,"cells":{"code":{"kind":"string","value":"function testSendAsIsNotIgnoredIfAttachmentsPresent() {\n\t\t$this->Controller->EmailTest->to = 'postmaster@localhost';\n\t\t$this->Controller->EmailTest->from = 'noreply@example.com';\n\t\t$this->Controller->EmailTest->subject = 'Attachment Test';\n\t\t$this->Controller->EmailTest->replyTo = 'noreply@example.com';\n\t\t$this->Controller->EmailTest->template = null;\n\t\t$this->Controller->EmailTest->delivery = 'debug';\n\t\t$this->Controller->EmailTest->attachments = array(__FILE__);\n\t\t$body = '

This is the body of the message

';\n\n\t\t$this->Controller->EmailTest->sendAs = 'html';\n\t\t$this->assertTrue($this->Controller->EmailTest->send($body));\n\t\t$msg = $this->Controller->Session->read('Message.email.message');\n\t\t$this->assertNoPattern('/text\\/plain/', $msg);\n\t\t$this->assertPattern('/text\\/html/', $msg);\n\n\t\t$this->Controller->EmailTest->sendAs = 'text';\n\t\t$this->assertTrue($this->Controller->EmailTest->send($body));\n\t\t$msg = $this->Controller->Session->read('Message.email.message');\n\t\t$this->assertPattern('/text\\/plain/', $msg);\n\t\t$this->assertNoPattern('/text\\/html/', $msg);\n\n\t\t$this->Controller->EmailTest->sendAs = 'both';\n\t\t$this->assertTrue($this->Controller->EmailTest->send($body));\n\t\t$msg = $this->Controller->Session->read('Message.email.message');\n\n\t\t$this->assertNoPattern('/text\\/plain/', $msg);\n\t\t$this->assertNoPattern('/text\\/html/', $msg);\n\t\t$this->assertPattern('/multipart\\/alternative/', $msg);\n\t}"},"docstring":{"kind":"string","value":"testSendAsIsNotIgnoredIfAttachmentsPresent method\n\n@return void\n@access public"},"func_name":{"kind":"string","value":"testSendAsIsNotIgnoredIfAttachmentsPresent"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/email.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903674,"cells":{"code":{"kind":"string","value":"function testNoDoubleNewlinesInHeaders() {\n\t\t$this->Controller->EmailTest->to = 'postmaster@localhost';\n\t\t$this->Controller->EmailTest->from = 'noreply@example.com';\n\t\t$this->Controller->EmailTest->subject = 'Attachment Test';\n\t\t$this->Controller->EmailTest->replyTo = 'noreply@example.com';\n\t\t$this->Controller->EmailTest->template = null;\n\t\t$this->Controller->EmailTest->delivery = 'debug';\n\t\t$body = '

This is the body of the message

';\n\n\t\t$this->Controller->EmailTest->sendAs = 'both';\n\t\t$this->assertTrue($this->Controller->EmailTest->send($body));\n\t\t$msg = $this->Controller->Session->read('Message.email.message');\n\n\t\t$this->assertNoPattern('/\\n\\nContent-Transfer-Encoding/', $msg);\n\t\t$this->assertPattern('/\\nContent-Transfer-Encoding/', $msg);\n\t}"},"docstring":{"kind":"string","value":"testNoDoubleNewlinesInHeaders function\n\n@return void\n@access public"},"func_name":{"kind":"string","value":"testNoDoubleNewlinesInHeaders"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/email.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903675,"cells":{"code":{"kind":"string","value":"function testReset() {\n\t\t$this->Controller->EmailTest->template = 'test_template';\n\t\t$this->Controller->EmailTest->to = 'test.recipient@example.com';\n\t\t$this->Controller->EmailTest->from = 'test.sender@example.com';\n\t\t$this->Controller->EmailTest->replyTo = 'test.replyto@example.com';\n\t\t$this->Controller->EmailTest->return = 'test.return@example.com';\n\t\t$this->Controller->EmailTest->cc = array('cc1@example.com', 'cc2@example.com');\n\t\t$this->Controller->EmailTest->bcc = array('bcc1@example.com', 'bcc2@example.com');\n\t\t$this->Controller->EmailTest->date = 'Today!';\n\t\t$this->Controller->EmailTest->subject = 'Test subject';\n\t\t$this->Controller->EmailTest->additionalParams = 'X-additional-header';\n\t\t$this->Controller->EmailTest->delivery = 'smtp';\n\t\t$this->Controller->EmailTest->smtpOptions['host'] = 'blah';\n\t\t$this->Controller->EmailTest->smtpOptions['timeout'] = 0.5;\n\t\t$this->Controller->EmailTest->attachments = array('attachment1', 'attachment2');\n\t\t$this->Controller->EmailTest->textMessage = 'This is the body of the message';\n\t\t$this->Controller->EmailTest->htmlMessage = 'This is the body of the message';\n\t\t$this->Controller->EmailTest->messageId = false;\n\n\t\t$this->assertFalse($this->Controller->EmailTest->send('Should not work'));\n\n\t\t$this->Controller->EmailTest->reset();\n\n\t\t$this->assertNull($this->Controller->EmailTest->template);\n\t\t$this->assertIdentical($this->Controller->EmailTest->to, array());\n\t\t$this->assertNull($this->Controller->EmailTest->from);\n\t\t$this->assertNull($this->Controller->EmailTest->replyTo);\n\t\t$this->assertNull($this->Controller->EmailTest->return);\n\t\t$this->assertIdentical($this->Controller->EmailTest->cc, array());\n\t\t$this->assertIdentical($this->Controller->EmailTest->bcc, array());\n\t\t$this->assertNull($this->Controller->EmailTest->date);\n\t\t$this->assertNull($this->Controller->EmailTest->subject);\n\t\t$this->assertNull($this->Controller->EmailTest->additionalParams);\n\t\t$this->assertIdentical($this->Controller->EmailTest->getHeaders(), array());\n\t\t$this->assertNull($this->Controller->EmailTest->getBoundary());\n\t\t$this->assertIdentical($this->Controller->EmailTest->getMessage(), array());\n\t\t$this->assertNull($this->Controller->EmailTest->smtpError);\n\t\t$this->assertIdentical($this->Controller->EmailTest->attachments, array());\n\t\t$this->assertNull($this->Controller->EmailTest->textMessage);\n\t\t$this->assertTrue($this->Controller->EmailTest->messageId);\n\t\t$this->assertEqual('mail', $this->Controller->EmailTest->delivery);\n\t}"},"docstring":{"kind":"string","value":"testReset method\n\n@access public\n@return void"},"func_name":{"kind":"string","value":"testReset"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/email.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903676,"cells":{"code":{"kind":"string","value":"function testMessageId() {\n\t\t$this->Controller->EmailTest->to = 'postmaster@localhost';\n\t\t$this->Controller->EmailTest->from = 'noreply@example.com';\n\t\t$this->Controller->EmailTest->subject = 'Cake Debug Test';\n\t\t$this->Controller->EmailTest->replyTo = 'noreply@example.com';\n\t\t$this->Controller->EmailTest->template = null;\n\n\t\t$this->Controller->EmailTest->delivery = 'debug';\n\t\t$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));\n\t\t$result = $this->Controller->Session->read('Message.email.message');\n\n\t\t$this->assertPattern('/Message-ID: \\<[a-f0-9]{32}@' . env('HTTP_HOST') . '\\>\\n/', $result);\n\n\t\t$this->Controller->EmailTest->messageId = '<22091985.998877@localhost>';\n\n\t\t$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));\n\t\t$result = $this->Controller->Session->read('Message.email.message');\n\n\t\t$this->assertPattern('/Message-ID: <22091985.998877@localhost>\\n/', $result);\n\n\t\t$this->Controller->EmailTest->messageId = false;\n\n\t\t$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));\n\t\t$result = $this->Controller->Session->read('Message.email.message');\n\n\t\t$this->assertNoPattern('/Message-ID:/', $result);\n\t}"},"docstring":{"kind":"string","value":"testMessageId method\n\n@access public\n@return void"},"func_name":{"kind":"string","value":"testMessageId"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/email.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903677,"cells":{"code":{"kind":"string","value":"function testSendMessage() {\n\t\t$this->Controller->EmailTest->delivery = 'getMessage';\n\t\t$this->Controller->EmailTest->lineLength = 70;\n\n\t\t$text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.';\n\t\t$this->Controller->EmailTest->sendAs = 'text';\n\t\t$result = $this->Controller->EmailTest->send($text);\n\t\t$expected = array(\n\t\t\t'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do',\n\t\t\t'eiusmod tempor incididunt ut labore et dolore magna aliqua.',\n\t\t\t'',\n\t\t\t''\n\t\t);\n\t\t$this->assertEqual($expected, $result);\n\n\t\t$text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.';\n\t\t$this->Controller->EmailTest->sendAs = 'html';\n\t\t$result = $this->Controller->EmailTest->send($text);\n\t\t$expected = array(\n\t\t\t$text,\n\t\t\t'',\n\t\t\t''\n\t\t);\n\t\t$this->assertEqual($expected, $result);\n\t}"},"docstring":{"kind":"string","value":"testSendMessage method\n\n@access public\n@return void"},"func_name":{"kind":"string","value":"testSendMessage"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/email.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903678,"cells":{"code":{"kind":"string","value":"function testFormatAddressAliases() {\n\t\t$result = $this->Controller->EmailTest->formatAddress('email@example.com');\n\t\t$this->assertEqual($result, 'email@example.com');\n\n\t\t$result = $this->Controller->EmailTest->formatAddress('alias ');\n\t\t$this->assertEqual($result, 'alias ');\n\t\t\n\t\t$result = $this->Controller->EmailTest->formatAddress('alias');\n\t\t$this->assertEqual($result, 'alias ');\n\n\t\t$result = $this->Controller->EmailTest->formatAddress('email@example.com');\n\t\t$this->assertEqual($result, 'email@example.com');\n\n\t\t$result = $this->Controller->EmailTest->formatAddress('');\n\t\t$this->assertEqual($result, '');\n\n\t\t$result = $this->Controller->EmailTest->formatAddress('email@example.com', true);\n\t\t$this->assertEqual($result, '');\n\n\t\t$result = $this->Controller->EmailTest->formatAddress('', true);\n\t\t$this->assertEqual($result, '');\n\n\t\t$result = $this->Controller->EmailTest->formatAddress('alias name ', true);\n\t\t$this->assertEqual($result, '');\n\t}"},"docstring":{"kind":"string","value":"Test that _formatName doesn't jack up email addresses with alias parts.\n\n@return void"},"func_name":{"kind":"string","value":"testFormatAddressAliases"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/email.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903679,"cells":{"code":{"kind":"string","value":"function __construct($params = array()) {\n\t\tforeach ($params as $key => $val) {\n\t\t\t$this->{$key} = $val;\n\t\t}\n\t\tparent::__construct();\n\t}"},"docstring":{"kind":"string","value":"construct method\n\n@param array $params\n@access private\n@return void"},"func_name":{"kind":"string","value":"__construct"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/request_handler.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903680,"cells":{"code":{"kind":"string","value":"function destination() {\n\t\t$this->viewPath = 'posts';\n\t\t$this->render('index');\n\t}"},"docstring":{"kind":"string","value":"test method for ajax redirection\n\n@return void"},"func_name":{"kind":"string","value":"destination"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/request_handler.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903681,"cells":{"code":{"kind":"string","value":"function param_method($one = null, $two = null) {\n\t\techo \"one: $one two: $two\";\n\t\t$this->autoRender = false;\n\t}"},"docstring":{"kind":"string","value":"test method for ajax redirection + parameter parsing\n\n@return void"},"func_name":{"kind":"string","value":"param_method"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/request_handler.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903682,"cells":{"code":{"kind":"string","value":"function ajax2_layout() {\n\t\tif ($this->autoLayout) {\n\t\t\t$this->layout = 'ajax2';\n\t\t}\n\t\t$this->destination();\n\t}"},"docstring":{"kind":"string","value":"test method for testing layout rendering when isAjax()\n\n@return void"},"func_name":{"kind":"string","value":"ajax2_layout"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/request_handler.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903683,"cells":{"code":{"kind":"string","value":"function __construct($params = array()) {\n\t\tforeach ($params as $key => $val) {\n\t\t\t$this->{$key} = $val;\n\t\t}\n\t\tparent::__construct();\n\t}"},"docstring":{"kind":"string","value":"construct method\n\n@param array $params\n@access private\n@return void"},"func_name":{"kind":"string","value":"__construct"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/request_handler.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903684,"cells":{"code":{"kind":"string","value":"function beforeFilter() {\n\t\t$this->RequestHandler->enabled = false;\n\t}"},"docstring":{"kind":"string","value":"beforeFilter method\n\n@return void\n@access public"},"func_name":{"kind":"string","value":"beforeFilter"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/request_handler.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903685,"cells":{"code":{"kind":"string","value":"function _init() {\n\t\t$this->Controller = new RequestHandlerTestController(array('components' => array('RequestHandler')));\n\t\t$this->Controller->constructClasses();\n\t\t$this->RequestHandler =& $this->Controller->RequestHandler;\n\t}"},"docstring":{"kind":"string","value":"init method\n\n@access protected\n@return void"},"func_name":{"kind":"string","value":"_init"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/request_handler.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903686,"cells":{"code":{"kind":"string","value":"function endTest() {\n\t\tunset($this->RequestHandler);\n\t\tunset($this->Controller);\n\t\tif (!headers_sent()) {\n\t\t\theader('Content-type: text/html'); //reset content type.\n\t\t}\n\t\tApp::build();\n\t}"},"docstring":{"kind":"string","value":"endTest method\n\n@access public\n@return void"},"func_name":{"kind":"string","value":"endTest"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/request_handler.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903687,"cells":{"code":{"kind":"string","value":"function testInitializeCallback() {\n\t\t$this->assertNull($this->RequestHandler->ext);\n\n\t\t$this->_init();\n\t\t$this->Controller->params['url']['ext'] = 'rss';\n\t\t$this->RequestHandler->initialize($this->Controller);\n\t\t$this->assertEqual($this->RequestHandler->ext, 'rss');\n\n\t\t$settings = array(\n\t\t\t'ajaxLayout' => 'test_ajax'\n\t\t);\n\t\t$this->RequestHandler->initialize($this->Controller, $settings);\n\t\t$this->assertEqual($this->RequestHandler->ajaxLayout, 'test_ajax');\n\t}"},"docstring":{"kind":"string","value":"testInitializeCallback method\n\n@access public\n@return void"},"func_name":{"kind":"string","value":"testInitializeCallback"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/request_handler.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903688,"cells":{"code":{"kind":"string","value":"function testDisabling() {\n\t\t$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';\n\t\t$this->_init();\n\t\t$this->Controller->Component->initialize($this->Controller);\n\t\t$this->Controller->beforeFilter();\n\t\t$this->Controller->Component->startup($this->Controller);\n\t\t$this->assertEqual($this->Controller->params, array('isAjax' => true));\n\n\t\t$this->Controller = new RequestHandlerTestDisabledController(array('components' => array('RequestHandler')));\n\t\t$this->Controller->constructClasses();\n\t\t$this->Controller->Component->initialize($this->Controller);\n\t\t$this->Controller->beforeFilter();\n\t\t$this->Controller->Component->startup($this->Controller);\n\t\t$this->assertEqual($this->Controller->params, array());\n\t\tunset($_SERVER['HTTP_X_REQUESTED_WITH']);\n\t}"},"docstring":{"kind":"string","value":"testDisabling method\n\n@access public\n@return void"},"func_name":{"kind":"string","value":"testDisabling"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/request_handler.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903689,"cells":{"code":{"kind":"string","value":"function testAutoResponseType() {\n\t\t$this->Controller->ext = '.thtml';\n\t\t$this->Controller->params['url']['ext'] = 'rss';\n\t\t$this->RequestHandler->initialize($this->Controller);\n\t\t$this->RequestHandler->startup($this->Controller);\n\t\t$this->assertEqual($this->Controller->ext, '.ctp');\n\t}"},"docstring":{"kind":"string","value":"testAutoResponseType method\n\n@access public\n@return void"},"func_name":{"kind":"string","value":"testAutoResponseType"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/request_handler.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903690,"cells":{"code":{"kind":"string","value":"function testAutoAjaxLayout() {\n\t\t$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';\n\t\t$this->RequestHandler->startup($this->Controller);\n\t\t$this->assertTrue($this->Controller->layout, $this->RequestHandler->ajaxLayout);\n\n\t\t$this->_init();\n\t\t$this->Controller->params['url']['ext'] = 'js';\n\t\t$this->RequestHandler->initialize($this->Controller);\n\t\t$this->RequestHandler->startup($this->Controller);\n\t\t$this->assertNotEqual($this->Controller->layout, 'ajax');\n\n\t\tunset($_SERVER['HTTP_X_REQUESTED_WITH']);\n\t}"},"docstring":{"kind":"string","value":"testAutoAjaxLayout method\n\n@access public\n@return void"},"func_name":{"kind":"string","value":"testAutoAjaxLayout"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/request_handler.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903691,"cells":{"code":{"kind":"string","value":"function testStartupCallback() {\n\t\t$_SERVER['REQUEST_METHOD'] = 'PUT';\n\t\t$_SERVER['CONTENT_TYPE'] = 'application/xml';\n\t\t$this->RequestHandler->startup($this->Controller);\n\t\t$this->assertTrue(is_array($this->Controller->data));\n\t\t$this->assertFalse(is_object($this->Controller->data));\n\t}"},"docstring":{"kind":"string","value":"testStartupCallback method\n\n@access public\n@return void"},"func_name":{"kind":"string","value":"testStartupCallback"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/request_handler.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903692,"cells":{"code":{"kind":"string","value":"function testNonAjaxRedirect() {\n\t\t$this->RequestHandler->initialize($this->Controller);\n\t\t$this->RequestHandler->startup($this->Controller);\n\t\t$this->assertNull($this->RequestHandler->beforeRedirect($this->Controller, '/'));\n\t}"},"docstring":{"kind":"string","value":"testNonAjaxRedirect method\n\n@access public\n@return void"},"func_name":{"kind":"string","value":"testNonAjaxRedirect"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/request_handler.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903693,"cells":{"code":{"kind":"string","value":"function testRenderAs() {\n\t\t$this->assertFalse(in_array('Xml', $this->Controller->helpers));\n\t\t$this->RequestHandler->renderAs($this->Controller, 'xml');\n\t\t$this->assertTrue(in_array('Xml', $this->Controller->helpers));\n\n\t\t$this->Controller->viewPath = 'request_handler_test\\\\xml';\n\t\t$this->RequestHandler->renderAs($this->Controller, 'js');\n\t\t$this->assertEqual($this->Controller->viewPath, 'request_handler_test' . DS . 'js');\n\t}"},"docstring":{"kind":"string","value":"testRenderAs method\n\n@access public\n@return void"},"func_name":{"kind":"string","value":"testRenderAs"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/request_handler.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903694,"cells":{"code":{"kind":"string","value":"function testRespondAs() {\n\t\t$RequestHandler = new NoStopRequestHandler();\n\t\t$RequestHandler->expectAt(0, '_header', array('Content-Type: application/json'));\n\t\t$RequestHandler->expectAt(1, '_header', array('Content-Type: text/xml'));\n\n\t\t$result = $RequestHandler->respondAs('json');\n\t\t$this->assertTrue($result);\n\n\t\t$result = $RequestHandler->respondAs('text/xml');\n\t\t$this->assertTrue($result);\n\t}"},"docstring":{"kind":"string","value":"test that respondAs works as expected.\n\n@return void"},"func_name":{"kind":"string","value":"testRespondAs"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/request_handler.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903695,"cells":{"code":{"kind":"string","value":"function testRespondAsWithAttachment() {\n\t\t$RequestHandler = new NoStopRequestHandler();\n\t\t$RequestHandler->expectAt(0, '_header', array('Content-Disposition: attachment; filename=\"myfile.xml\"'));\n\t\t$RequestHandler->expectAt(1, '_header', array('Content-Type: text/xml'));\n\n\t\t$result = $RequestHandler->respondAs('xml', array('attachment' => 'myfile.xml'));\n\t\t$this->assertTrue($result);\n\t}"},"docstring":{"kind":"string","value":"test that attachment headers work with respondAs\n\n@return void"},"func_name":{"kind":"string","value":"testRespondAsWithAttachment"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/request_handler.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903696,"cells":{"code":{"kind":"string","value":"function testRenderAsCalledTwice() {\n\t\t$this->RequestHandler->renderAs($this->Controller, 'xml');\n\t\t$this->assertEqual($this->Controller->viewPath, 'request_handler_test' . DS . 'xml');\n\t\t$this->assertEqual($this->Controller->layoutPath, 'xml');\n\n\t\t$this->assertTrue(in_array('Xml', $this->Controller->helpers));\n\n\t\t$this->RequestHandler->renderAs($this->Controller, 'js');\n\t\t$this->assertEqual($this->Controller->viewPath, 'request_handler_test' . DS . 'js');\n\t\t$this->assertEqual($this->Controller->layoutPath, 'js');\n\t\t$this->assertTrue(in_array('Js', $this->Controller->helpers));\n\t}"},"docstring":{"kind":"string","value":"test that calling renderAs() more than once continues to work.\n\n@link #6466\n@return void"},"func_name":{"kind":"string","value":"testRenderAsCalledTwice"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/request_handler.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903697,"cells":{"code":{"kind":"string","value":"function testRequestClientTypes() {\n\t\t$this->assertFalse($this->RequestHandler->isFlash());\n\t\t$_SERVER['HTTP_USER_AGENT'] = 'Shockwave Flash';\n\t\t$this->assertTrue($this->RequestHandler->isFlash());\n\t\tunset($_SERVER['HTTP_USER_AGENT'], $_SERVER['HTTP_X_REQUESTED_WITH']);\n\n\t\t$this->assertFalse($this->RequestHandler->isAjax());\n\t\t$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';\n\t\t$_SERVER['HTTP_X_PROTOTYPE_VERSION'] = '1.5';\n\t\t$this->assertTrue($this->RequestHandler->isAjax());\n\t\t$this->assertEqual($this->RequestHandler->getAjaxVersion(), '1.5');\n\n\t\tunset($_SERVER['HTTP_X_REQUESTED_WITH'], $_SERVER['HTTP_X_PROTOTYPE_VERSION']);\n\t\t$this->assertFalse($this->RequestHandler->isAjax());\n\t\t$this->assertFalse($this->RequestHandler->getAjaxVersion());\n\t}"},"docstring":{"kind":"string","value":"testRequestClientTypes method\n\n@access public\n@return void"},"func_name":{"kind":"string","value":"testRequestClientTypes"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/request_handler.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903698,"cells":{"code":{"kind":"string","value":"function testFlashDetection() {\n\t\t$_agent = env('HTTP_USER_AGENT');\n\t\t$_SERVER['HTTP_USER_AGENT'] = 'Shockwave Flash';\n\t\t$this->assertTrue($this->RequestHandler->isFlash());\n\n\t\t$_SERVER['HTTP_USER_AGENT'] = 'Adobe Flash';\n\t\t$this->assertTrue($this->RequestHandler->isFlash());\n\n\t\t$_SERVER['HTTP_USER_AGENT'] = 'Adobe Flash Player 9';\n\t\t$this->assertTrue($this->RequestHandler->isFlash());\n\n\t\t$_SERVER['HTTP_USER_AGENT'] = 'Adobe Flash Player 10';\n\t\t$this->assertTrue($this->RequestHandler->isFlash());\n\n\t\t$_SERVER['HTTP_USER_AGENT'] = 'Shock Flash';\n\t\t$this->assertFalse($this->RequestHandler->isFlash());\n\n\t\t$_SERVER['HTTP_USER_AGENT'] = $_agent;\n\t}"},"docstring":{"kind":"string","value":"Tests the detection of various Flash versions\n\n@access public\n@return void"},"func_name":{"kind":"string","value":"testFlashDetection"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/request_handler.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php"},"license":{"kind":"string","value":"MIT"}}},{"rowIdx":903699,"cells":{"code":{"kind":"string","value":"function testRequestContentTypes() {\n\t\t$_SERVER['REQUEST_METHOD'] = 'GET';\n\t\t$this->assertNull($this->RequestHandler->requestedWith());\n\n\t\t$_SERVER['REQUEST_METHOD'] = 'POST';\n\t\t$_SERVER['CONTENT_TYPE'] = 'application/json';\n\t\t$this->assertEqual($this->RequestHandler->requestedWith(), 'json');\n\n\t\t$result = $this->RequestHandler->requestedWith(array('json', 'xml'));\n\t\t$this->assertEqual($result, 'json');\n\n\t\t$result =$this->RequestHandler->requestedWith(array('rss', 'atom'));\n\t\t$this->assertFalse($result);\n\n\t\t$_SERVER['HTTP_ACCEPT'] = 'text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,*/*';\n\t\t$this->_init();\n\t\t$this->assertTrue($this->RequestHandler->isXml());\n\t\t$this->assertFalse($this->RequestHandler->isAtom());\n\t\t$this->assertFalse($this->RequestHandler->isRSS());\n\n\t\t$_SERVER['HTTP_ACCEPT'] = 'application/atom+xml,text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,*/*';\n\t\t$this->_init();\n\t\t$this->assertTrue($this->RequestHandler->isAtom());\n\t\t$this->assertFalse($this->RequestHandler->isRSS());\n\n\t\t$_SERVER['HTTP_ACCEPT'] = 'application/rss+xml,text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,*/*';\n\t\t$this->_init();\n\t\t$this->assertFalse($this->RequestHandler->isAtom());\n\t\t$this->assertTrue($this->RequestHandler->isRSS());\n\n\t\t$this->assertFalse($this->RequestHandler->isWap());\n\t\t$_SERVER['HTTP_ACCEPT'] = 'text/vnd.wap.wml,text/html,text/plain,image/png,*/*';\n\t\t$this->_init();\n\t\t$this->assertTrue($this->RequestHandler->isWap());\n\n\t\t$_SERVER['HTTP_ACCEPT'] = 'application/rss+xml ;q=0.9 , text/xml, application/xml,application/xhtml+xml';\n\t\t$this->_init();\n\t\t$this->assertFalse($this->RequestHandler->isAtom());\n\t\t$this->assertTrue($this->RequestHandler->isRSS());\n\t}"},"docstring":{"kind":"string","value":"testRequestContentTypes method\n\n@access public\n@return void"},"func_name":{"kind":"string","value":"testRequestContentTypes"},"language":{"kind":"string","value":"php"},"repo":{"kind":"string","value":"Datawalke/Coordino"},"path":{"kind":"string","value":"cake/tests/cases/libs/controller/components/request_handler.test.php"},"url":{"kind":"string","value":"https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php"},"license":{"kind":"string","value":"MIT"}}}],"truncated":false,"partial":false},"paginationData":{"pageIndex":9036,"numItemsPerPage":100,"numTotalItems":905197,"offset":903600,"length":100}},"jwt":"eyJhbGciOiJFZERTQSJ9.eyJyZWFkIjp0cnVlLCJwZXJtaXNzaW9ucyI6eyJyZXBvLmNvbnRlbnQucmVhZCI6dHJ1ZX0sImlhdCI6MTc1NjMyMzM0NCwic3ViIjoiL2RhdGFzZXRzL1NodXUxMjEyMS9waHAtdHJlZXNpdHRlci1maWx0ZXJlZC1kYXRhc2V0c1YyIiwiZXhwIjoxNzU2MzI2OTQ0LCJpc3MiOiJodHRwczovL2h1Z2dpbmdmYWNlLmNvIn0.mCYehd9c5_9PlBChQsL0x59f7uu7NiveubIIxZg9NUiW7GlhiA4_5YNrxsv_QSThr0f_66G0_nyKbydXq7CxDA","displayUrls":true},"discussionsStats":{"closed":0,"open":0,"total":0},"fullWidth":true,"hasGatedAccess":true,"hasFullAccess":true,"isEmbedded":false,"savedQueries":{"community":[],"user":[]}}">
code
stringlengths
31
1.39M
docstring
stringlengths
23
16.8k
func_name
stringlengths
1
126
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
166
url
stringlengths
50
220
license
stringclasses
7 values
function beforeFilter() { $this->TestAuth->ajaxLogin = 'test_element'; $this->TestAuth->userModel = 'AuthUser'; $this->TestAuth->RequestHandler->ajaxLayout = 'ajax2'; }
beforeFilter method @access public @return void
beforeFilter
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function add() { if ($this->TestAuth->testStop !== true) { echo 'Added Record'; } }
add method @access public @return void
add
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function redirect($url, $status = null, $exit = true) { $this->testUrl = Router::url($url); return false; }
redirect method @param mixed $url @param mixed $status @param mixed $exit @access public @return void
redirect
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function startTest() { $this->_server = $_SERVER; $this->_env = $_ENV; $this->_securitySalt = Configure::read('Security.salt'); Configure::write('Security.salt', 'JfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi'); $this->_acl = Configure::read('Acl'); Configure::write('Acl.database', 'test_suite'); Configure::write('Acl.classname', 'DbAcl'); $this->Controller =& new AuthTestController(); $this->Controller->Component->init($this->Controller); $this->Controller->Component->initialize($this->Controller); $this->Controller->beforeFilter(); ClassRegistry::addObject('view', new View($this->Controller)); $this->Controller->Session->delete('Auth'); $this->Controller->Session->delete('Message.auth'); Router::reload(); $this->initialized = true; }
startTest method @access public @return void
startTest
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function endTest() { $_SERVER = $this->_server; $_ENV = $this->_env; Configure::write('Acl', $this->_acl); Configure::write('Security.salt', $this->_securitySalt); $this->Controller->Session->delete('Auth'); $this->Controller->Session->delete('Message.auth'); ClassRegistry::flush(); unset($this->Controller, $this->AuthUser); }
endTest method @access public @return void
endTest
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testIdentify() { $this->AuthUser =& new AuthUser(); $user['id'] = 1; $user['username'] = 'mariano'; $user['password'] = Security::hash(Configure::read('Security.salt') . 'cake'); $this->AuthUser->save($user, false); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $this->assertTrue($this->Controller->Auth->identify($user)); }
testIdentify method @access public @return void
testIdentify
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testIdentifyWithConditions() { $this->AuthUser =& new AuthUser(); $user['id'] = 1; $user['username'] = 'mariano'; $user['password'] = Security::hash(Configure::read('Security.salt') . 'cake'); $this->AuthUser->save($user, false); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->startup($this->Controller); $this->Controller->Auth->userModel = 'AuthUser'; $this->assertFalse($this->Controller->Auth->identify($user, array('AuthUser.id >' => 2))); $this->Controller->Auth->userScope = array('id >' => 2); $this->assertFalse($this->Controller->Auth->identify($user)); $this->assertTrue($this->Controller->Auth->identify($user, false)); }
testIdentifyWithConditions method @access public @return void
testIdentifyWithConditions
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testLogin() { $this->AuthUser =& new AuthUser(); $user['id'] = 1; $user['username'] = 'mariano'; $user['password'] = Security::hash(Configure::read('Security.salt') . 'cake'); $this->AuthUser->save($user, false); $authUser = $this->AuthUser->find(); $this->Controller->data['AuthUser']['username'] = $authUser['AuthUser']['username']; $this->Controller->data['AuthUser']['password'] = 'cake'; $this->Controller->params = Router::parse('auth_test/login'); $this->Controller->params['url']['url'] = 'auth_test/login'; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = 'auth_test/login'; $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); $expected = array('AuthUser' => array( 'id' => 1, 'username' => 'mariano', 'created' => '2007-03-17 01:16:23', 'updated' => date('Y-m-d H:i:s') )); $this->assertEqual($user, $expected); $this->Controller->Session->delete('Auth'); $this->Controller->data['AuthUser']['username'] = 'blah'; $this->Controller->data['AuthUser']['password'] = ''; $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); $this->assertFalse($user); $this->Controller->Session->delete('Auth'); $this->Controller->data['AuthUser']['username'] = 'now() or 1=1 --'; $this->Controller->data['AuthUser']['password'] = ''; $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); $this->assertFalse($user); $this->Controller->Session->delete('Auth'); $this->Controller->data['AuthUser']['username'] = 'now() or 1=1 # something'; $this->Controller->data['AuthUser']['password'] = ''; $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); $this->assertFalse($user); $this->Controller->Session->delete('Auth'); $this->Controller->Auth->userModel = 'UuidUser'; $this->Controller->Auth->login('47c36f9c-bc00-4d17-9626-4e183ca6822b'); $user = $this->Controller->Auth->user(); $expected = array('UuidUser' => array( 'id' => '47c36f9c-bc00-4d17-9626-4e183ca6822b', 'title' => 'Unique record 1', 'count' => 2, 'created' => '2008-03-13 01:16:23', 'updated' => '2008-03-13 01:18:31' )); $this->assertEqual($user, $expected); $this->Controller->Session->delete('Auth'); }
testLogin method @access public @return void
testLogin
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testLoginActionNotSettingAuthRedirect() { $_referer = $_SERVER['HTTP_REFERER']; $_SERVER['HTTP_REFERER'] = '/pages/display/about'; $this->Controller->data = array(); $this->Controller->params = Router::parse('auth_test/login'); $this->Controller->params['url']['url'] = 'auth_test/login'; $this->Controller->Session->delete('Auth'); $this->Controller->Auth->loginRedirect = '/users/dashboard'; $this->Controller->Auth->loginAction = 'auth_test/login'; $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $redirect = $this->Controller->Session->read('Auth.redirect'); $this->assertNull($redirect); }
test that being redirected to the login page, with no post data does not set the session value. Saving the session value in this circumstance can cause the user to be redirected to an already public page. @return void
testLoginActionNotSettingAuthRedirect
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testAuthorizeFalse() { $this->AuthUser =& new AuthUser(); $user = $this->AuthUser->find(); $this->Controller->Session->write('Auth', $user); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->authorize = false; $this->Controller->params = Router::parse('auth_test/add'); $result = $this->Controller->Auth->startup($this->Controller); $this->assertTrue($result); $this->Controller->Session->delete('Auth'); $result = $this->Controller->Auth->startup($this->Controller); $this->assertFalse($result); $this->assertTrue($this->Controller->Session->check('Message.auth')); $this->Controller->params = Router::parse('auth_test/camelCase'); $result = $this->Controller->Auth->startup($this->Controller); $this->assertFalse($result); }
testAuthorizeFalse method @access public @return void
testAuthorizeFalse
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testAuthorizeController() { $this->AuthUser =& new AuthUser(); $user = $this->AuthUser->find(); $this->Controller->Session->write('Auth', $user); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->authorize = 'controller'; $this->Controller->params = Router::parse('auth_test/add'); $result = $this->Controller->Auth->startup($this->Controller); $this->assertTrue($result); $this->Controller->params['testControllerAuth'] = 1; $result = $this->Controller->Auth->startup($this->Controller); $this->assertTrue($this->Controller->Session->check('Message.auth')); $this->assertFalse($result); $this->Controller->Session->delete('Auth'); }
testAuthorizeController method @access public @return void
testAuthorizeController
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testAuthorizeModel() { $this->AuthUser =& new AuthUser(); $user = $this->AuthUser->find(); $this->Controller->Session->write('Auth', $user); $this->Controller->params['controller'] = 'auth_test'; $this->Controller->params['action'] = 'add'; $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->authorize = array('model'=>'AuthUser'); $result = $this->Controller->Auth->startup($this->Controller); $this->assertTrue($result); $this->Controller->Session->delete('Auth'); $this->Controller->Auth->startup($this->Controller); $this->assertTrue($this->Controller->Session->check('Message.auth')); $result = $this->Controller->Auth->isAuthorized(); $this->assertFalse($result); }
testAuthorizeModel method @access public @return void
testAuthorizeModel
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testAuthorizeCrud() { $this->AuthUser =& new AuthUser(); $user = $this->AuthUser->find(); $this->Controller->Session->write('Auth', $user); $this->Controller->params['controller'] = 'auth_test'; $this->Controller->params['action'] = 'add'; $this->Controller->Acl->name = 'DbAclTest'; $this->Controller->Acl->Aro->id = null; $this->Controller->Acl->Aro->create(array('alias' => 'Roles')); $result = $this->Controller->Acl->Aro->save(); $this->assertTrue($result); $parent = $this->Controller->Acl->Aro->id; $this->Controller->Acl->Aro->create(array('parent_id' => $parent, 'alias' => 'Admin')); $result = $this->Controller->Acl->Aro->save(); $this->assertTrue($result); $parent = $this->Controller->Acl->Aro->id; $this->Controller->Acl->Aro->create(array( 'model' => 'AuthUser', 'parent_id' => $parent, 'foreign_key' => 1, 'alias'=> 'mariano' )); $result = $this->Controller->Acl->Aro->save(); $this->assertTrue($result); $this->Controller->Acl->Aco->create(array('alias' => 'Root')); $result = $this->Controller->Acl->Aco->save(); $this->assertTrue($result); $parent = $this->Controller->Acl->Aco->id; $this->Controller->Acl->Aco->create(array('parent_id' => $parent, 'alias' => 'AuthTest')); $result = $this->Controller->Acl->Aco->save(); $this->assertTrue($result); $this->Controller->Acl->allow('Roles/Admin', 'Root'); $this->Controller->Acl->allow('Roles/Admin', 'Root/AuthTest'); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->authorize = 'crud'; $this->Controller->Auth->actionPath = 'Root/'; $this->Controller->Auth->startup($this->Controller); $this->assertTrue($this->Controller->Auth->isAuthorized()); $this->Controller->Session->delete('Auth'); $this->Controller->Auth->startup($this->Controller); $this->assertTrue($this->Controller->Session->check('Message.auth')); }
testAuthorizeCrud method @access public @return void
testAuthorizeCrud
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testAuthorizeActions() { $this->AuthUser =& new AuthUser(); $user = $this->AuthUser->find(); $this->Controller->Session->write('Auth', $user); $this->Controller->params['controller'] = 'auth_test'; $this->Controller->params['action'] = 'add'; $this->Controller->Acl =& new AuthTestMockAclComponent(); $this->Controller->Acl->setReturnValue('check', true); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->authorize = 'actions'; $this->Controller->Auth->actionPath = 'Root/'; $this->Controller->Acl->expectAt(0, 'check', array( $user, 'Root/AuthTest/add' )); $this->Controller->Auth->startup($this->Controller); $this->assertTrue($this->Controller->Auth->isAuthorized()); }
test authorize = 'actions' setting. @return void
testAuthorizeActions
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testAllowDenyAll() { $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->allow('*'); $this->Controller->Auth->deny('add', 'camelcase'); $this->Controller->params['action'] = 'delete'; $this->assertTrue($this->Controller->Auth->startup($this->Controller)); $this->Controller->params['action'] = 'add'; $this->assertFalse($this->Controller->Auth->startup($this->Controller)); $this->Controller->params['action'] = 'Add'; $this->assertFalse($this->Controller->Auth->startup($this->Controller)); $this->Controller->params['action'] = 'camelCase'; $this->assertFalse($this->Controller->Auth->startup($this->Controller)); $this->Controller->Auth->allow('*'); $this->Controller->Auth->deny(array('add', 'camelcase')); $this->Controller->params['action'] = 'camelCase'; $this->assertFalse($this->Controller->Auth->startup($this->Controller)); }
Tests that deny always takes precedence over allow @access public @return void
testAllowDenyAll
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testActionMethod() { $this->Controller->params['controller'] = 'auth_test'; $this->Controller->params['action'] = 'add'; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->actionPath = 'ROOT/'; $result = $this->Controller->Auth->action(); $this->assertEqual($result, 'ROOT/AuthTest/add'); $result = $this->Controller->Auth->action(':controller'); $this->assertEqual($result, 'ROOT/AuthTest'); $result = $this->Controller->Auth->action(':controller'); $this->assertEqual($result, 'ROOT/AuthTest'); $this->Controller->params['plugin'] = 'test_plugin'; $this->Controller->params['controller'] = 'auth_test'; $this->Controller->params['action'] = 'add'; $this->Controller->Auth->initialize($this->Controller); $result = $this->Controller->Auth->action(); $this->assertEqual($result, 'ROOT/TestPlugin/AuthTest/add'); }
test the action() method @return void
testActionMethod
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testDenyWithCamelCaseMethods() { $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->allow('*'); $this->Controller->Auth->deny('add', 'camelCase'); $url = '/auth_test/camelCase'; $this->Controller->params = Router::parse($url); $this->Controller->params['url']['url'] = Router::normalize($url); $this->assertFalse($this->Controller->Auth->startup($this->Controller)); }
test that deny() converts camel case inputs to lowercase. @return void
testDenyWithCamelCaseMethods
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testAllowedActionsWithCamelCaseMethods() { $url = '/auth_test/camelCase'; $this->Controller->params = Router::parse($url); $this->Controller->params['url']['url'] = Router::normalize($url); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->allow('*'); $result = $this->Controller->Auth->startup($this->Controller); $this->assertTrue($result, 'startup() should return true, as action is allowed. %s'); $url = '/auth_test/camelCase'; $this->Controller->params = Router::parse($url); $this->Controller->params['url']['url'] = Router::normalize($url); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->allowedActions = array('delete', 'camelCase', 'add'); $result = $this->Controller->Auth->startup($this->Controller); $this->assertTrue($result, 'startup() should return true, as action is allowed. %s'); $this->Controller->Auth->allowedActions = array('delete', 'add'); $result = $this->Controller->Auth->startup($this->Controller); $this->assertFalse($result, 'startup() should return false, as action is not allowed. %s'); $url = '/auth_test/delete'; $this->Controller->params = Router::parse($url); $this->Controller->params['url']['url'] = Router::normalize($url); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->allow(array('delete', 'add')); $result = $this->Controller->Auth->startup($this->Controller); $this->assertTrue($result, 'startup() should return true, as action is allowed. %s'); }
test that allow() and allowedActions work with camelCase method names. @return void
testAllowedActionsWithCamelCaseMethods
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testLoginRedirect() { if (isset($_SERVER['HTTP_REFERER'])) { $backup = $_SERVER['HTTP_REFERER']; } else { $backup = null; } $_SERVER['HTTP_REFERER'] = false; $this->Controller->Session->write('Auth', array( 'AuthUser' => array('id' => '1', 'username' => 'nate') )); $this->Controller->params = Router::parse('users/login'); $this->Controller->params['url']['url'] = 'users/login'; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->loginRedirect = array( 'controller' => 'pages', 'action' => 'display', 'welcome' ); $this->Controller->Auth->startup($this->Controller); $expected = Router::normalize($this->Controller->Auth->loginRedirect); $this->assertEqual($expected, $this->Controller->Auth->redirect()); $this->Controller->Session->delete('Auth'); //empty referer no session $_SERVER['HTTP_REFERER'] = false; $_ENV['HTTP_REFERER'] = false; putenv('HTTP_REFERER='); $url = '/posts/view/1'; $this->Controller->Session->write('Auth', array( 'AuthUser' => array('id' => '1', 'username' => 'nate')) ); $this->Controller->testUrl = null; $this->Controller->params = Router::parse($url); array_push($this->Controller->methods, 'view', 'edit', 'index'); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->authorize = 'controller'; $this->Controller->params['testControllerAuth'] = true; $this->Controller->Auth->loginAction = array( 'controller' => 'AuthTest', 'action' => 'login' ); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $expected = Router::normalize('/'); $this->assertEqual($expected, $this->Controller->testUrl); $this->Controller->Session->delete('Auth'); $_SERVER['HTTP_REFERER'] = Router::url('/admin/', true); $this->Controller->Session->write('Auth', array( 'AuthUser' => array('id'=>'1', 'username'=>'nate')) ); $this->Controller->params['url']['url'] = 'auth_test/login'; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = 'auth_test/login'; $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->loginRedirect = false; $this->Controller->Auth->startup($this->Controller); $expected = Router::normalize('/admin'); $this->assertEqual($expected, $this->Controller->Auth->redirect()); //Ticket #4750 //named params $this->Controller->Session->delete('Auth'); $url = '/posts/index/year:2008/month:feb'; $this->Controller->params = Router::parse($url); $this->Controller->params['url']['url'] = Router::normalize($url); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $expected = Router::normalize('posts/index/year:2008/month:feb'); $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); //passed args $this->Controller->Session->delete('Auth'); $url = '/posts/view/1'; $this->Controller->params = Router::parse($url); $this->Controller->params['url']['url'] = Router::normalize($url); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $expected = Router::normalize('posts/view/1'); $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); // QueryString parameters $_back = $_GET; $_GET = array( 'url' => '/posts/index/29', 'print' => 'true', 'refer' => 'menu' ); $this->Controller->Session->delete('Auth'); $url = '/posts/index/29?print=true&refer=menu'; $this->Controller->params = Dispatcher::parseParams($url); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $expected = Router::normalize('posts/index/29?print=true&refer=menu'); $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); $_GET = array( 'url' => '/posts/index/29', 'print' => 'true', 'refer' => 'menu', 'ext' => 'html' ); $this->Controller->Session->delete('Auth'); $url = '/posts/index/29?print=true&refer=menu'; $this->Controller->params = Dispatcher::parseParams($url); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $expected = Router::normalize('posts/index/29?print=true&refer=menu'); $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); $_GET = $_back; //external authed action $_SERVER['HTTP_REFERER'] = 'http://webmail.example.com/view/message'; $this->Controller->Session->delete('Auth'); $url = '/posts/edit/1'; $this->Controller->params = Router::parse($url); $this->Controller->params['url']['url'] = Router::normalize($url); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $expected = Router::normalize('/posts/edit/1'); $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); //external direct login link $_SERVER['HTTP_REFERER'] = 'http://webmail.example.com/view/message'; $this->Controller->Session->delete('Auth'); $url = '/AuthTest/login'; $this->Controller->params = Router::parse($url); $this->Controller->params['url']['url'] = Router::normalize($url); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $expected = Router::normalize('/'); $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); $_SERVER['HTTP_REFERER'] = $backup; $this->Controller->Session->delete('Auth'); }
testLoginRedirect method @access public @return void
testLoginRedirect
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testNoRedirectOn404() { $this->Controller->Session->delete('Auth'); $this->Controller->Auth->initialize($this->Controller); $this->Controller->params = Router::parse('auth_test/something_totally_wrong'); $result = $this->Controller->Auth->startup($this->Controller); $this->assertTrue($result, 'Auth redirected a missing action %s'); }
Ensure that no redirect is performed when a 404 is reached And the user doesn't have a session. @return void
testNoRedirectOn404
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testEmptyUsernameOrPassword() { $this->AuthUser =& new AuthUser(); $user['id'] = 1; $user['username'] = 'mariano'; $user['password'] = Security::hash(Configure::read('Security.salt') . 'cake'); $this->AuthUser->save($user, false); $authUser = $this->AuthUser->find(); $this->Controller->data['AuthUser']['username'] = ''; $this->Controller->data['AuthUser']['password'] = ''; $this->Controller->params = Router::parse('auth_test/login'); $this->Controller->params['url']['url'] = 'auth_test/login'; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = 'auth_test/login'; $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); $this->assertTrue($this->Controller->Session->check('Message.auth')); $this->assertEqual($user, false); $this->Controller->Session->delete('Auth'); }
testEmptyUsernameOrPassword method @access public @return void
testEmptyUsernameOrPassword
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testInjection() { $this->AuthUser =& new AuthUser(); $this->AuthUser->id = 2; $this->AuthUser->saveField('password', Security::hash(Configure::read('Security.salt') . 'cake')); $this->Controller->data['AuthUser']['username'] = 'nate'; $this->Controller->data['AuthUser']['password'] = 'cake'; $this->Controller->params = Router::parse('auth_test/login'); $this->Controller->params['url']['url'] = 'auth_test/login'; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = 'auth_test/login'; $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $this->assertTrue(is_array($this->Controller->Auth->user())); $this->Controller->Session->delete($this->Controller->Auth->sessionKey); $this->Controller->data['AuthUser']['username'] = 'nate'; $this->Controller->data['AuthUser']['password'] = 'cake1'; $this->Controller->params['url']['url'] = 'auth_test/login'; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = 'auth_test/login'; $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $this->assertTrue(is_null($this->Controller->Auth->user())); $this->Controller->Session->delete($this->Controller->Auth->sessionKey); $this->Controller->data['AuthUser']['username'] = '> n'; $this->Controller->data['AuthUser']['password'] = 'cake'; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->startup($this->Controller); $this->assertTrue(is_null($this->Controller->Auth->user())); unset($this->Controller->data['AuthUser']['password']); $this->Controller->data['AuthUser']['username'] = "1'1"; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->startup($this->Controller); $this->assertTrue(is_null($this->Controller->Auth->user())); unset($this->Controller->data['AuthUser']['username']); $this->Controller->data['AuthUser']['password'] = "1'1"; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->startup($this->Controller); $this->assertTrue(is_null($this->Controller->Auth->user())); }
testInjection method @access public @return void
testInjection
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testHashPasswords() { $this->Controller->Auth->userModel = 'AuthUser'; $data['AuthUser']['password'] = 'superSecret'; $data['AuthUser']['username'] = '[email protected]'; $return = $this->Controller->Auth->hashPasswords($data); $expected = $data; $expected['AuthUser']['password'] = Security::hash($expected['AuthUser']['password'], null, true); $this->assertEqual($return, $expected); $data['Wrong']['password'] = 'superSecret'; $data['Wrong']['username'] = '[email protected]'; $data['AuthUser']['password'] = 'IcantTellYou'; $return = $this->Controller->Auth->hashPasswords($data); $expected = $data; $expected['AuthUser']['password'] = Security::hash($expected['AuthUser']['password'], null, true); $this->assertEqual($return, $expected); if (PHP5) { $xml = array( 'User' => array( 'username' => '[email protected]', 'password' => 'bruceWayne', ) ); $data =& new Xml($xml); $return = $this->Controller->Auth->hashPasswords($data); $expected = $data; $this->assertEqual($return, $expected); } }
test Hashing of passwords @return void
testHashPasswords
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testCustomRoute() { Router::reload(); Router::connect( '/:lang/:controller/:action/*', array('lang' => null), array('lang' => '[a-z]{2,3}') ); $url = '/en/users/login'; $this->Controller->params = Router::parse($url); Router::setRequestInfo(array($this->Controller->passedArgs, array( 'base' => null, 'here' => $url, 'webroot' => '/', 'passedArgs' => array(), 'argSeparator' => ':', 'namedArgs' => array() ))); $this->AuthUser =& new AuthUser(); $user = array( 'id' => 1, 'username' => 'felix', 'password' => Security::hash(Configure::read('Security.salt') . 'cake' )); $user = $this->AuthUser->save($user, false); $this->Controller->data['AuthUser'] = array('username' => 'felix', 'password' => 'cake'); $this->Controller->params['url']['url'] = substr($url, 1); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('lang' => 'en', 'controller' => 'users', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); $this->assertTrue(!!$user); $this->Controller->Session->delete('Auth'); Router::reload(); Router::connect('/', array('controller' => 'people', 'action' => 'login')); $url = '/'; $this->Controller->params = Router::parse($url); Router::setRequestInfo(array($this->Controller->passedArgs, array( 'base' => null, 'here' => $url, 'webroot' => '/', 'passedArgs' => array(), 'argSeparator' => ':', 'namedArgs' => array() ))); $this->Controller->data['AuthUser'] = array('username' => 'felix', 'password' => 'cake'); $this->Controller->params['url']['url'] = substr($url, 1); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('controller' => 'people', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); $this->assertTrue(!!$user); }
testCustomRoute method @access public @return void
testCustomRoute
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testCustomField() { Router::reload(); $this->AuthUserCustomField =& new AuthUserCustomField(); $user = array( 'id' => 1, 'email' => '[email protected]', 'password' => Security::hash(Configure::read('Security.salt') . 'cake' )); $user = $this->AuthUserCustomField->save($user, false); Router::connect('/', array('controller' => 'people', 'action' => 'login')); $url = '/'; $this->Controller->params = Router::parse($url); Router::setRequestInfo(array($this->Controller->passedArgs, array( 'base' => null, 'here' => $url, 'webroot' => '/', 'passedArgs' => array(), 'argSeparator' => ':', 'namedArgs' => array() ))); $this->Controller->data['AuthUserCustomField'] = array('email' => '[email protected]', 'password' => 'cake'); $this->Controller->params['url']['url'] = substr($url, 1); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->fields = array('username' => 'email', 'password' => 'password'); $this->Controller->Auth->loginAction = array('controller' => 'people', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUserCustomField'; $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); $this->assertTrue(!!$user); }
testCustomField method @access public @return void
testCustomField
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testAdminRoute() { $prefixes = Configure::read('Routing.prefixes'); Configure::write('Routing.prefixes', array('admin')); Router::reload(); $url = '/admin/auth_test/add'; $this->Controller->params = Router::parse($url); $this->Controller->params['url']['url'] = ltrim($url, '/'); Router::setRequestInfo(array( array( 'pass' => array(), 'action' => 'add', 'plugin' => null, 'controller' => 'auth_test', 'admin' => true, 'url' => array('url' => $this->Controller->params['url']['url']) ), array( 'base' => null, 'here' => $url, 'webroot' => '/', 'passedArgs' => array(), ) )); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array( 'admin' => true, 'controller' => 'auth_test', 'action' => 'login' ); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $this->assertEqual($this->Controller->testUrl, '/admin/auth_test/login'); Configure::write('Routing.prefixes', $prefixes); }
testAdminRoute method @access public @return void
testAdminRoute
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testPluginModel() { // Adding plugins Cache::delete('object_map', '_cake_core_'); App::build(array( 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), 'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS) ), true); App::objects('plugin', null, false); $PluginModel =& ClassRegistry::init('TestPlugin.TestPluginAuthUser'); $user['id'] = 1; $user['username'] = 'gwoo'; $user['password'] = Security::hash(Configure::read('Security.salt') . 'cake'); $PluginModel->save($user, false); $authUser = $PluginModel->find(); $this->Controller->data['TestPluginAuthUser']['username'] = $authUser['TestPluginAuthUser']['username']; $this->Controller->data['TestPluginAuthUser']['password'] = 'cake'; $this->Controller->params = Router::parse('auth_test/login'); $this->Controller->params['url']['url'] = 'auth_test/login'; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = 'auth_test/login'; $this->Controller->Auth->userModel = 'TestPlugin.TestPluginAuthUser'; $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); $expected = array('TestPluginAuthUser' => array( 'id' => 1, 'username' => 'gwoo', 'created' => '2007-03-17 01:16:23', 'updated' => date('Y-m-d H:i:s') )); $this->assertEqual($user, $expected); $sessionKey = $this->Controller->Auth->sessionKey; $this->assertEqual('Auth.TestPluginAuthUser', $sessionKey); $this->Controller->Auth->loginAction = null; $this->Controller->Auth->__setDefaults(); $loginAction = $this->Controller->Auth->loginAction; $expected = array( 'controller' => 'test_plugin_auth_users', 'action' => 'login', 'plugin' => 'test_plugin' ); $this->assertEqual($loginAction, $expected); // Reverting changes Cache::delete('object_map', '_cake_core_'); App::build(); App::objects('plugin', null, false); }
testPluginModel method @access public @return void
testPluginModel
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testAjaxLogin() { App::build(array('views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS))); $_SERVER['HTTP_X_REQUESTED_WITH'] = "XMLHttpRequest"; if (!class_exists('dispatcher')) { require CAKE . 'dispatcher.php'; } ob_start(); $Dispatcher =& new Dispatcher(); $Dispatcher->dispatch('/ajax_auth/add', array('return' => 1)); $result = ob_get_clean(); $this->assertEqual("Ajax!\nthis is the test element", str_replace("\r\n", "\n", $result)); unset($_SERVER['HTTP_X_REQUESTED_WITH']); }
testAjaxLogin method @access public @return void
testAjaxLogin
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testLoginActionRedirect() { $admin = Configure::read('Routing.admin'); Configure::write('Routing.admin', 'admin'); Router::reload(); $url = '/admin/auth_test/login'; $this->Controller->params = Router::parse($url); $this->Controller->params['url']['url'] = ltrim($url, '/'); Router::setRequestInfo(array( array( 'pass' => array(), 'action' => 'admin_login', 'plugin' => null, 'controller' => 'auth_test', 'admin' => true, 'url' => array('url' => $this->Controller->params['url']['url']), ), array( 'base' => null, 'here' => $url, 'webroot' => '/', 'passedArgs' => array(), ) )); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->loginAction = array('admin' => true, 'controller' => 'auth_test', 'action' => 'login'); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); $this->assertNull($this->Controller->testUrl); Configure::write('Routing.admin', $admin); }
testLoginActionRedirect method @access public @return void
testLoginActionRedirect
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testShutDown() { $this->Controller->Session->write('Auth.redirect', 'foo'); $this->Controller->Auth->_loggedIn = true; $this->Controller->Auth->shutdown($this->Controller); $this->assertFalse($this->Controller->Session->read('Auth.redirect')); }
Tests that shutdown destroys the redirect session var @access public @return void
testShutDown
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testInitializeAndRoutingPrefixes() { $restore = Configure::read('Routing'); Configure::write('Routing.prefixes', array('admin', 'super_user')); Router::reload(); $this->Controller->Auth->initialize($this->Controller); $this->assertTrue(isset($this->Controller->Auth->actionMap['delete'])); $this->assertTrue(isset($this->Controller->Auth->actionMap['view'])); $this->assertTrue(isset($this->Controller->Auth->actionMap['add'])); $this->assertTrue(isset($this->Controller->Auth->actionMap['admin_view'])); $this->assertTrue(isset($this->Controller->Auth->actionMap['super_user_delete'])); Configure::write('Routing', $restore); }
test the initialize callback and its interactions with Router::prefixes() @return void
testInitializeAndRoutingPrefixes
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testComponentSettings() { $this->Controller =& new AuthTestController(); $this->Controller->components = array( 'Auth' => array( 'fields' => array('username' => 'email', 'password' => 'password'), 'loginAction' => array('controller' => 'people', 'action' => 'login'), 'userModel' => 'AuthUserCustomField', 'sessionKey' => 'AltAuth.AuthUserCustomField' ), 'Session' ); $this->Controller->Component->init($this->Controller); $this->Controller->Component->initialize($this->Controller); Router::reload(); $this->AuthUserCustomField =& new AuthUserCustomField(); $user = array( 'id' => 1, 'email' => '[email protected]', 'password' => Security::hash(Configure::read('Security.salt') . 'cake' )); $user = $this->AuthUserCustomField->save($user, false); Router::connect('/', array('controller' => 'people', 'action' => 'login')); $url = '/'; $this->Controller->params = Router::parse($url); Router::setRequestInfo(array($this->Controller->passedArgs, array( 'base' => null, 'here' => $url, 'webroot' => '/', 'passedArgs' => array(), 'argSeparator' => ':', 'namedArgs' => array() ))); $this->Controller->data['AuthUserCustomField'] = array('email' => '[email protected]', 'password' => 'cake'); $this->Controller->params['url']['url'] = substr($url, 1); $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); $this->assertTrue(!!$user); $expected = array( 'fields' => array('username' => 'email', 'password' => 'password'), 'loginAction' => array('controller' => 'people', 'action' => 'login'), 'logoutRedirect' => array('controller' => 'people', 'action' => 'login'), 'userModel' => 'AuthUserCustomField', 'sessionKey' => 'AltAuth.AuthUserCustomField' ); $this->assertEqual($expected['fields'], $this->Controller->Auth->fields); $this->assertEqual($expected['loginAction'], $this->Controller->Auth->loginAction); $this->assertEqual($expected['logoutRedirect'], $this->Controller->Auth->logoutRedirect); $this->assertEqual($expected['userModel'], $this->Controller->Auth->userModel); $this->assertEqual($expected['sessionKey'], $this->Controller->Auth->sessionKey); }
test $settings in Controller::$components @access public @return void
testComponentSettings
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function testLogout() { $this->Controller->Session->write('Auth.User.id', '1'); $this->Controller->Session->write('Auth.redirect', '/users/login'); $this->Controller->Auth->logoutRedirect = '/'; $result = $this->Controller->Auth->logout(); $this->assertEqual($result, '/'); $this->assertNull($this->Controller->Session->read('Auth.AuthUser')); $this->assertNull($this->Controller->Session->read('Auth.redirect')); }
test that logout deletes the session variables. and returns the correct url @return void
testLogout
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/auth.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/auth.test.php
MIT
function beforeFilter() { $this->Cookie->name = 'CakeTestCookie'; $this->Cookie->time = 10; $this->Cookie->path = '/'; $this->Cookie->domain = ''; $this->Cookie->secure = false; $this->Cookie->key = 'somerandomhaskey'; }
beforeFilter method @access public @return void
beforeFilter
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/cookie.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/cookie.test.php
MIT
function testInitialize() { $settings = array( 'time' => '5 days', 'path' => '/' ); $this->Controller->Cookie->initialize($this->Controller, $settings); $this->assertEqual($this->Controller->Cookie->time, $settings['time']); $this->assertEqual($this->Controller->Cookie->path, $settings['path']); }
test that initialize sets settings from components array @return void
testInitialize
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/cookie.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/cookie.test.php
MIT
function testNoErrorOnNonArrayData() { $this->Controller->Cookie->destroy(); $_COOKIE['CakeTestCookie'] = 'kaboom'; $this->assertNull($this->Controller->Cookie->read('value')); }
test that no error is issued for non array data. @return void
testNoErrorOnNonArrayData
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/cookie.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/cookie.test.php
MIT
function testDeleteRemovesChildren() { $_COOKIE['CakeTestCookie'] = array( 'User' => array('email' => '[email protected]', 'name' => 'mark'), 'other' => 'value' ); $this->Controller->Cookie->startup(); $this->assertEqual('mark', $this->Controller->Cookie->read('User.name')); $this->Controller->Cookie->delete('User'); $this->assertFalse($this->Controller->Cookie->read('User.email')); $this->Controller->Cookie->destroy(); }
test that deleting a top level keys kills the child elements too. @return void
testDeleteRemovesChildren
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/cookie.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/cookie.test.php
MIT
function testDeleteChildrenNotExist() { $this->assertNull($this->Controller->Cookie->delete('NotFound')); $this->assertNull($this->Controller->Cookie->delete('Not.Found')); }
Test deleting recursively with keys that don't exist. @return void
testDeleteChildrenNotExist
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/cookie.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/cookie.test.php
MIT
function testForwardsCompatibility() { if ($this->skipIf(!function_exists('json_decode'), 'no json_decode, skipping.')) { return; } $_COOKIE['CakeTestCookie'] = array( 'JSON' => '{"name":"value"}', 'Empty' => '', 'String' => '{"somewhat:"broken"}' ); $this->Controller->Cookie->startup($this->Controller); $this->assertEqual(array('name' => 'value'), $this->Controller->Cookie->read('JSON')); $this->assertEqual('value', $this->Controller->Cookie->read('JSON.name')); $this->assertEqual('', $this->Controller->Cookie->read('Empty')); $this->assertEqual('{"somewhat:"broken"}', $this->Controller->Cookie->read('String')); }
Test that 1.3 can read 2.0 format codes if json_encode exists. @return void
testForwardsCompatibility
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/cookie.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/cookie.test.php
MIT
function __encrypt($value) { if (is_array($value)) { $value = $this->__implode($value); } return "Q2FrZQ==." . base64_encode(Security::cipher($value, $this->Controller->Cookie->key)); }
encrypt method @param mixed $value @return string @access private
__encrypt
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/cookie.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/cookie.test.php
MIT
function __implode($array) { $string = ''; foreach ($array as $key => $value) { $string .= ',' . $key . '|' . $value; } return substr($string, 1); }
implode method @param array $value @return string @access private
__implode
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/cookie.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/cookie.test.php
MIT
function smtpSend($data, $code = '250') { return parent::_smtpSend($data, $code); }
smtpSend method override for testing @access public @return mixed
smtpSend
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function setConnectionSocket(&$socket) { $this->__smtpConnection = $socket; }
Convenience setter method for testing. @access public @return void
setConnectionSocket
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function _getSocket($config) { if (empty($this->__smtpConnection)) { parent::_getSocket($config); } }
Allows mocks to be used with tests. @param array $config @return void
_getSocket
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function getConnectionSocket() { return $this->__smtpConnection; }
Convenience getter method for testing. @access public @return mixed
getConnectionSocket
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function setHeaders($headers) { $this->__header += $headers; }
Convenience setter for testing. @access public @return void
setHeaders
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function getHeaders() { return $this->__header; }
Convenience getter for testing. @access public @return array
getHeaders
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function getBoundary() { return $this->__boundary; }
Convenience getter for testing. @access public @return string
getBoundary
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function getMessage() { return $this->__message; }
Convenience getter for testing. @access public @return string
getMessage
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function _getMessage() { return $this->__message; }
Convenience getter for testing. @access protected @return string
_getMessage
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function strip($content, $message = false) { return parent::_strip($content, $message); }
Convenience method for testing. @access public @return string
strip
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function setUp() { $this->_appEncoding = Configure::read('App.encoding'); Configure::write('App.encoding', 'UTF-8'); $this->Controller =& new EmailTestController(); restore_error_handler(); @$this->Controller->Component->init($this->Controller); set_error_handler('simpleTestErrorHandler'); $this->Controller->EmailTest->initialize($this->Controller, array()); ClassRegistry::addObject('view', new View($this->Controller)); App::build(array( 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) )); }
setUp method @access public @return void
setUp
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function tearDown() { Configure::write('App.encoding', $this->_appEncoding); App::build(); $this->Controller->Session->delete('Message'); restore_error_handler(); ClassRegistry::flush(); }
tearDown method @access public @return void
tearDown
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function __osFix($string) { return str_replace(array("\r\n", "\r"), "\n", $string); }
osFix method @param string $string @access private @return string
__osFix
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSmtpConfig() { if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { return; } $this->Controller->EmailTest->delivery = 'smtp'; $this->Controller->EmailTest->smtpOptions = array(); $this->Controller->EmailTest->send('anything'); $config = array( 'host' => 'localhost', 'port' => 25, 'protocol' => 'smtp', 'timeout' => 30 ); $this->assertEqual($config, $this->Controller->EmailTest->smtpOptions); $this->Controller->EmailTest->smtpOptions = array('port' => 80); $this->Controller->EmailTest->send('anything'); $config['port'] = 80; $this->assertEqual($config, $this->Controller->EmailTest->smtpOptions); }
testSmtpConfig method @access public @return void
testSmtpConfig
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testBadSmtpSend() { if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { return; } $this->Controller->EmailTest->smtpOptions['host'] = 'blah'; $this->Controller->EmailTest->delivery = 'smtp'; $this->assertFalse($this->Controller->EmailTest->send('Should not work')); }
testBadSmtpSend method @access public @return void
testBadSmtpSend
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSmtpSend() { if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { return; } $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake SMTP test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'smtp'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->Controller->EmailTest->_debug = true; $this->Controller->EmailTest->sendAs = 'text'; $expect = <<<TEMPDOC <pre>Host: localhost Port: 25 Timeout: 30 To: postmaster@localhost From: [email protected] Subject: Cake SMTP test Header: To: postmaster@localhost From: [email protected] Reply-To: [email protected] Subject: Cake SMTP test X-Mailer: CakePHP Email Component Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bitParameters: Message: This is the body of the message </pre> TEMPDOC; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect)); }
testSmtpSend method @access public @return void
testSmtpSend
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSmtpEhlo() { if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { return; } $connection =& new CakeSocket(array('protocol'=>'smtp', 'host' => 'localhost', 'port' => 25)); $this->Controller->EmailTest->setConnectionSocket($connection); $this->Controller->EmailTest->smtpOptions['timeout'] = 10; $this->assertTrue($connection->connect()); $this->assertTrue($this->Controller->EmailTest->smtpSend(null, '220') !== false); $this->skipIf($this->Controller->EmailTest->smtpSend('EHLO locahost', '250') === false, '%s do not support EHLO.'); $connection->disconnect(); $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake SMTP test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'smtp'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->Controller->EmailTest->_debug = true; $this->Controller->EmailTest->sendAs = 'text'; $expect = <<<TEMPDOC <pre>Host: localhost Port: 25 Timeout: 30 To: postmaster@localhost From: [email protected] Subject: Cake SMTP test Header: To: postmaster@localhost From: [email protected] Reply-To: [email protected] Subject: Cake SMTP test X-Mailer: CakePHP Email Component Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bitParameters: Message: This is the body of the message </pre> TEMPDOC; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect)); }
testSmtpEhlo method @access public @return void
testSmtpEhlo
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSmtpSendMultipleTo() { if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { return; } $this->Controller->EmailTest->reset(); $this->Controller->EmailTest->to = array('postmaster@localhost', 'root@localhost'); $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake SMTP multiple To test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->_debug = true; $this->Controller->EmailTest->sendAs = 'text'; $this->Controller->EmailTest->delivery = 'smtp'; $socket = new MockEmailSocket(); $socket->setReturnValue('connect', true); $this->Controller->EmailTest->setConnectionSocket($socket); $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->assertPattern('/EHLO localhost\n/', $this->Controller->EmailTest->smtpSend); $this->assertPattern('/MAIL FROM: <noreply@example\.com>\n/', $this->Controller->EmailTest->smtpSend); $this->assertPattern('/RCPT TO: <postmaster@localhost>\n/', $this->Controller->EmailTest->smtpSend); $this->assertPattern('/RCPT TO: <root@localhost>\n/', $this->Controller->EmailTest->smtpSend); $this->assertPattern( '/To: postmaster@localhost, root@localhost[\n\r]/', $this->Controller->EmailTest->smtpSend ); }
testSmtpSendMultipleTo method @access public @return void
testSmtpSendMultipleTo
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSmtpSendHostWithPort() { $bkp = env('HTTP_HOST'); $_SERVER['HTTP_HOST'] = 'localhost:8080'; $this->Controller->EmailTest->reset(); $this->Controller->EmailTest->to = array('root@localhost'); $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake SMTP host test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'smtp'; $this->Controller->EmailTest->sendAs = 'text'; $this->Controller->EmailTest->_debug = true; $socket = new MockEmailSocket(); $socket->setReturnValue('connect', true); $this->Controller->EmailTest->setConnectionSocket($socket); $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->assertPattern('/EHLO localhost\n/', $this->Controller->EmailTest->smtpSend); $_SERVER['HTTP_HOST'] = $bkp; }
test sending smtp from a host using a port. @return void
testSmtpSendHostWithPort
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testAuthenticatedSmtpSend() { if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { return; } $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake SMTP test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->smtpOptions['username'] = 'test'; $this->Controller->EmailTest->smtpOptions['password'] = 'testing'; $this->Controller->EmailTest->delivery = 'smtp'; $result = $this->Controller->EmailTest->send('This is the body of the message'); $code = substr($this->Controller->EmailTest->smtpError, 0, 3); $this->skipIf(!$code, '%s Authentication not enabled on server'); $this->assertFalse($result); $this->assertEqual($code, '535'); }
testAuthenticatedSmtpSend method @access public @return void
testAuthenticatedSmtpSend
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSendFormats() { $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake SMTP test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'debug'; $this->Controller->EmailTest->messageId = false; $date = date(DATE_RFC2822); $message = <<<MSGBLOC <pre>To: postmaster@localhost From: [email protected] Subject: Cake SMTP test Header: From: [email protected] Reply-To: [email protected] Date: $date X-Mailer: CakePHP Email Component Content-Type: {CONTENTTYPE} Content-Transfer-Encoding: 7bitParameters: Message: This is the body of the message </pre> MSGBLOC; $this->Controller->EmailTest->sendAs = 'text'; $expect = str_replace('{CONTENTTYPE}', 'text/plain; charset=UTF-8', $message); $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect)); $this->Controller->EmailTest->sendAs = 'html'; $expect = str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $message); $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect)); // TODO: better test for format of message sent? $this->Controller->EmailTest->sendAs = 'both'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $boundary = $this->Controller->EmailTest->getBoundary(); $expect = str_replace('{CONTENTTYPE}', 'multipart/alternative; boundary="alt-' . $boundary . '"', $message); $this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect)); }
testSendFormats method @access public @return void
testSendFormats
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testTemplates() { ClassRegistry::flush(); $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake SMTP test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->delivery = 'debug'; $this->Controller->EmailTest->messageId = false; $date = date(DATE_RFC2822); $header = <<<HEADBLOC To: postmaster@localhost From: [email protected] Subject: Cake SMTP test Header: From: [email protected] Reply-To: [email protected] Date: $date X-Mailer: CakePHP Email Component Content-Type: {CONTENTTYPE} Content-Transfer-Encoding: 7bitParameters: Message: HEADBLOC; $this->Controller->EmailTest->layout = 'default'; $this->Controller->EmailTest->template = 'default'; $text = <<<TEXTBLOC This is the body of the message This email was sent using the CakePHP Framework, http://cakephp.org. TEXTBLOC; $html = <<<HTMLBLOC <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>Email Test</title> </head> <body> <p> This is the body of the message</p><p> </p> <p>This email was sent using the <a href="http://cakephp.org">CakePHP Framework</a></p> </body> </html> HTMLBLOC; $this->Controller->EmailTest->sendAs = 'text'; $expect = '<pre>' . str_replace('{CONTENTTYPE}', 'text/plain; charset=UTF-8', $header) . $text . "\n" . '</pre>'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect)); $this->Controller->EmailTest->sendAs = 'html'; $expect = '<pre>' . str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $header) . $html . "\n" . '</pre>'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect)); $this->Controller->EmailTest->sendAs = 'both'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $boundary = $this->Controller->EmailTest->getBoundary(); $expect = str_replace('{CONTENTTYPE}', 'multipart/alternative; boundary="alt-' . $boundary . '"', $header); $expect .= '--alt-' . $boundary . "\n" . 'Content-Type: text/plain; charset=UTF-8' . "\n" . 'Content-Transfer-Encoding: 7bit' . "\n\n" . $text . "\n\n"; $expect .= '--alt-' . $boundary . "\n" . 'Content-Type: text/html; charset=UTF-8' . "\n" . 'Content-Transfer-Encoding: 7bit' . "\n\n" . $html . "\n\n"; $expect = '<pre>' . $expect . "--alt-$boundary--" . "\n\n" . '</pre>'; $this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect)); $this->Controller->EmailTest->reset(); $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake SMTP test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->delivery = 'debug'; $this->Controller->EmailTest->messageId = false; $html = <<<HTMLBLOC <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>Email Test</title> </head> <body> <p> This is the body of the message</p><p> </p> <p>This email was sent using the CakePHP Framework</p> </body> </html> HTMLBLOC; $this->Controller->EmailTest->sendAs = 'html'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message', 'default', 'thin')); $boundary = $this->Controller->EmailTest->getBoundary(); $expect = str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $header) . $html; $expect = '<pre>' . $expect . '</pre>'; $this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect)); $result = ClassRegistry::getObject('view'); $this->assertFalse($result); }
testTemplates method @access public @return void
testTemplates
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testTemplateNestedElements() { $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake SMTP test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->delivery = 'debug'; $this->Controller->EmailTest->messageId = false; $this->Controller->EmailTest->layout = 'default'; $this->Controller->EmailTest->template = 'nested_element'; $this->Controller->EmailTest->sendAs = 'html'; $this->Controller->helpers = array('Html'); $this->Controller->EmailTest->send(); $result = $this->Controller->Session->read('Message.email.message'); $this->assertPattern('/Test/', $result); $this->assertPattern('/http\:\/\/example\.com/', $result); }
test that elements used in email templates get helpers. @return void
testTemplateNestedElements
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSmtpSendSocket() { if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { return; } $this->Controller->EmailTest->smtpOptions['timeout'] = 10; $socket =& new CakeSocket(array_merge(array('protocol'=>'smtp'), $this->Controller->EmailTest->smtpOptions)); $this->Controller->EmailTest->setConnectionSocket($socket); $this->assertTrue($this->Controller->EmailTest->getConnectionSocket()); $response = $this->Controller->EmailTest->smtpSend('HELO', '250'); $this->assertPattern('/501 Syntax: HELO hostname/', $this->Controller->EmailTest->smtpError); $this->Controller->EmailTest->reset(); $response = $this->Controller->EmailTest->smtpSend('HELO somehostname', '250'); $this->assertNoPattern('/501 Syntax: HELO hostname/', $this->Controller->EmailTest->smtpError); }
testSmtpSendSocket method @access public @return void
testSmtpSendSocket
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSendDebug() { $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->cc = '[email protected]'; $this->Controller->EmailTest->bcc = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake Debug Test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'debug'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $result = $this->Controller->Session->read('Message.email.message'); $this->assertPattern('/To: postmaster@localhost\n/', $result); $this->assertPattern('/Subject: Cake Debug Test\n/', $result); $this->assertPattern('/Reply-To: [email protected]\n/', $result); $this->assertPattern('/From: [email protected]\n/', $result); $this->assertPattern('/Cc: [email protected]\n/', $result); $this->assertPattern('/Bcc: [email protected]\n/', $result); $this->assertPattern('/Date: ' . preg_quote(date(DATE_RFC2822)) . '\n/', $result); $this->assertPattern('/X-Mailer: CakePHP Email Component\n/', $result); $this->assertPattern('/Content-Type: text\/plain; charset=UTF-8\n/', $result); $this->assertPattern('/Content-Transfer-Encoding: 7bitParameters:\n/', $result); $this->assertPattern('/This is the body of the message/', $result); }
testSendDebug method @access public @return void
testSendDebug
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSendDebugWithNoSessions() { $session =& $this->Controller->Session; unset($this->Controller->Session); $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake Debug Test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'debug'; $result = $this->Controller->EmailTest->send('This is the body of the message'); $this->assertPattern('/To: postmaster@localhost\n/', $result); $this->assertPattern('/Subject: Cake Debug Test\n/', $result); $this->assertPattern('/Reply-To: [email protected]\n/', $result); $this->assertPattern('/From: [email protected]\n/', $result); $this->assertPattern('/Date: ' . preg_quote(date(DATE_RFC2822)) . '\n/', $result); $this->assertPattern('/X-Mailer: CakePHP Email Component\n/', $result); $this->assertPattern('/Content-Type: text\/plain; charset=UTF-8\n/', $result); $this->assertPattern('/Content-Transfer-Encoding: 7bitParameters:\n/', $result); $this->assertPattern('/This is the body of the message/', $result); $this->Controller->Session = $session; }
test send with delivery = debug and not using sessions. @return void
testSendDebugWithNoSessions
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testMessageRetrievalWithoutTemplate() { App::build(array( 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) )); $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake Debug Test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->layout = 'default'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'debug'; $text = $html = 'This is the body of the message'; $this->Controller->EmailTest->sendAs = 'both'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->assertEqual($this->Controller->EmailTest->textMessage, $this->__osFix($text)); $this->assertEqual($this->Controller->EmailTest->htmlMessage, $this->__osFix($html)); $this->Controller->EmailTest->sendAs = 'text'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->assertEqual($this->Controller->EmailTest->textMessage, $this->__osFix($text)); $this->assertNull($this->Controller->EmailTest->htmlMessage); $this->Controller->EmailTest->sendAs = 'html'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $this->assertNull($this->Controller->EmailTest->textMessage); $this->assertEqual($this->Controller->EmailTest->htmlMessage, $this->__osFix($html)); }
testMessageRetrievalWithoutTemplate method @access public @return void
testMessageRetrievalWithoutTemplate
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testMessageRetrievalWithTemplate() { App::build(array( 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) )); $this->Controller->set('value', 22091985); $this->Controller->set('title_for_layout', 'EmailTest'); $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake Debug Test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->layout = 'default'; $this->Controller->EmailTest->template = 'custom'; $this->Controller->EmailTest->delivery = 'debug'; $text = <<<TEXTBLOC Here is your value: 22091985 This email was sent using the CakePHP Framework, http://cakephp.org. TEXTBLOC; $html = <<<HTMLBLOC <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>EmailTest</title> </head> <body> <p>Here is your value: <b>22091985</b></p> <p>This email was sent using the <a href="http://cakephp.org">CakePHP Framework</a></p> </body> </html> HTMLBLOC; $this->Controller->EmailTest->sendAs = 'both'; $this->assertTrue($this->Controller->EmailTest->send()); $this->assertEqual($this->Controller->EmailTest->textMessage, $this->__osFix($text)); $this->assertEqual($this->Controller->EmailTest->htmlMessage, $this->__osFix($html)); $this->Controller->EmailTest->sendAs = 'text'; $this->assertTrue($this->Controller->EmailTest->send()); $this->assertEqual($this->Controller->EmailTest->textMessage, $this->__osFix($text)); $this->assertNull($this->Controller->EmailTest->htmlMessage); $this->Controller->EmailTest->sendAs = 'html'; $this->assertTrue($this->Controller->EmailTest->send()); $this->assertNull($this->Controller->EmailTest->textMessage); $this->assertEqual($this->Controller->EmailTest->htmlMessage, $this->__osFix($html)); }
testMessageRetrievalWithTemplate method @access public @return void
testMessageRetrievalWithTemplate
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSendContentArray() { $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake Debug Test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'debug'; $content = array('First line', 'Second line', 'Third line'); $this->assertTrue($this->Controller->EmailTest->send($content)); $result = $this->Controller->Session->read('Message.email.message'); $this->assertPattern('/To: postmaster@localhost\n/', $result); $this->assertPattern('/Subject: Cake Debug Test\n/', $result); $this->assertPattern('/Reply-To: [email protected]\n/', $result); $this->assertPattern('/From: [email protected]\n/', $result); $this->assertPattern('/X-Mailer: CakePHP Email Component\n/', $result); $this->assertPattern('/Content-Type: text\/plain; charset=UTF-8\n/', $result); $this->assertPattern('/Content-Transfer-Encoding: 7bitParameters:\n/', $result); $this->assertPattern('/First line\n/', $result); $this->assertPattern('/Second line\n/', $result); $this->assertPattern('/Third line\n/', $result); }
testContentArray method @access public @return void
testSendContentArray
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testDateProperty() { $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake Debug Test'; $this->Controller->EmailTest->date = 'Today!'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'debug'; $this->assertTrue($this->Controller->EmailTest->send('test message')); $result = $this->Controller->Session->read('Message.email.message'); $this->assertPattern('/Date: Today!\n/', $result); }
test setting a custom date. @return void
testDateProperty
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testContentStripping() { $content = "Previous content\n--alt-\nContent-TypeContent-Type:: text/html; charsetcharset==utf-8\nContent-Transfer-Encoding: 7bit"; $content .= "\n\n<p>My own html content</p>"; $result = $this->Controller->EmailTest->strip($content, true); $expected = "Previous content\n--alt-\n text/html; utf-8\n 7bit\n\n<p>My own html content</p>"; $this->assertEqual($result, $expected); $content = '<p>Some HTML content with an <a href="mailto:[email protected]">email link</a>'; $result = $this->Controller->EmailTest->strip($content, true); $expected = $content; $this->assertEqual($result, $expected); $content = '<p>Some HTML content with an '; $content .= '<a href="mailto:[email protected],[email protected]">email link</a>'; $result = $this->Controller->EmailTest->strip($content, true); $expected = $content; $this->assertEqual($result, $expected); $content = 'This is a test email to: you and whomever you forward it to'; $result = $this->Controller->EmailTest->strip($content, true); $expected = $content; $this->assertEqual($result, $expected); }
testContentStripping method @access public @return void
testContentStripping
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSendWithAttachments() { $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Attachment Test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'debug'; $this->Controller->EmailTest->attachments = array( __FILE__, 'some-name.php' => __FILE__ ); $body = '<p>This is the body of the message</p>'; $this->Controller->EmailTest->sendAs = 'text'; $this->assertTrue($this->Controller->EmailTest->send($body)); $msg = $this->Controller->Session->read('Message.email.message'); $this->assertPattern('/' . preg_quote('Content-Disposition: attachment; filename="email.test.php"') . '/', $msg); $this->assertPattern('/' . preg_quote('Content-Disposition: attachment; filename="some-name.php"') . '/', $msg); }
undocumented function @return void @access public
testSendWithAttachments
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSendAsIsNotIgnoredIfAttachmentsPresent() { $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Attachment Test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'debug'; $this->Controller->EmailTest->attachments = array(__FILE__); $body = '<p>This is the body of the message</p>'; $this->Controller->EmailTest->sendAs = 'html'; $this->assertTrue($this->Controller->EmailTest->send($body)); $msg = $this->Controller->Session->read('Message.email.message'); $this->assertNoPattern('/text\/plain/', $msg); $this->assertPattern('/text\/html/', $msg); $this->Controller->EmailTest->sendAs = 'text'; $this->assertTrue($this->Controller->EmailTest->send($body)); $msg = $this->Controller->Session->read('Message.email.message'); $this->assertPattern('/text\/plain/', $msg); $this->assertNoPattern('/text\/html/', $msg); $this->Controller->EmailTest->sendAs = 'both'; $this->assertTrue($this->Controller->EmailTest->send($body)); $msg = $this->Controller->Session->read('Message.email.message'); $this->assertNoPattern('/text\/plain/', $msg); $this->assertNoPattern('/text\/html/', $msg); $this->assertPattern('/multipart\/alternative/', $msg); }
testSendAsIsNotIgnoredIfAttachmentsPresent method @return void @access public
testSendAsIsNotIgnoredIfAttachmentsPresent
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testNoDoubleNewlinesInHeaders() { $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Attachment Test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'debug'; $body = '<p>This is the body of the message</p>'; $this->Controller->EmailTest->sendAs = 'both'; $this->assertTrue($this->Controller->EmailTest->send($body)); $msg = $this->Controller->Session->read('Message.email.message'); $this->assertNoPattern('/\n\nContent-Transfer-Encoding/', $msg); $this->assertPattern('/\nContent-Transfer-Encoding/', $msg); }
testNoDoubleNewlinesInHeaders function @return void @access public
testNoDoubleNewlinesInHeaders
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testReset() { $this->Controller->EmailTest->template = 'test_template'; $this->Controller->EmailTest->to = '[email protected]'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->return = '[email protected]'; $this->Controller->EmailTest->cc = array('[email protected]', '[email protected]'); $this->Controller->EmailTest->bcc = array('[email protected]', '[email protected]'); $this->Controller->EmailTest->date = 'Today!'; $this->Controller->EmailTest->subject = 'Test subject'; $this->Controller->EmailTest->additionalParams = 'X-additional-header'; $this->Controller->EmailTest->delivery = 'smtp'; $this->Controller->EmailTest->smtpOptions['host'] = 'blah'; $this->Controller->EmailTest->smtpOptions['timeout'] = 0.5; $this->Controller->EmailTest->attachments = array('attachment1', 'attachment2'); $this->Controller->EmailTest->textMessage = 'This is the body of the message'; $this->Controller->EmailTest->htmlMessage = 'This is the body of the message'; $this->Controller->EmailTest->messageId = false; $this->assertFalse($this->Controller->EmailTest->send('Should not work')); $this->Controller->EmailTest->reset(); $this->assertNull($this->Controller->EmailTest->template); $this->assertIdentical($this->Controller->EmailTest->to, array()); $this->assertNull($this->Controller->EmailTest->from); $this->assertNull($this->Controller->EmailTest->replyTo); $this->assertNull($this->Controller->EmailTest->return); $this->assertIdentical($this->Controller->EmailTest->cc, array()); $this->assertIdentical($this->Controller->EmailTest->bcc, array()); $this->assertNull($this->Controller->EmailTest->date); $this->assertNull($this->Controller->EmailTest->subject); $this->assertNull($this->Controller->EmailTest->additionalParams); $this->assertIdentical($this->Controller->EmailTest->getHeaders(), array()); $this->assertNull($this->Controller->EmailTest->getBoundary()); $this->assertIdentical($this->Controller->EmailTest->getMessage(), array()); $this->assertNull($this->Controller->EmailTest->smtpError); $this->assertIdentical($this->Controller->EmailTest->attachments, array()); $this->assertNull($this->Controller->EmailTest->textMessage); $this->assertTrue($this->Controller->EmailTest->messageId); $this->assertEqual('mail', $this->Controller->EmailTest->delivery); }
testReset method @access public @return void
testReset
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testMessageId() { $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = '[email protected]'; $this->Controller->EmailTest->subject = 'Cake Debug Test'; $this->Controller->EmailTest->replyTo = '[email protected]'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'debug'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $result = $this->Controller->Session->read('Message.email.message'); $this->assertPattern('/Message-ID: \<[a-f0-9]{32}@' . env('HTTP_HOST') . '\>\n/', $result); $this->Controller->EmailTest->messageId = '<22091985.998877@localhost>'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $result = $this->Controller->Session->read('Message.email.message'); $this->assertPattern('/Message-ID: <22091985.998877@localhost>\n/', $result); $this->Controller->EmailTest->messageId = false; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $result = $this->Controller->Session->read('Message.email.message'); $this->assertNoPattern('/Message-ID:/', $result); }
testMessageId method @access public @return void
testMessageId
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testSendMessage() { $this->Controller->EmailTest->delivery = 'getMessage'; $this->Controller->EmailTest->lineLength = 70; $text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'; $this->Controller->EmailTest->sendAs = 'text'; $result = $this->Controller->EmailTest->send($text); $expected = array( 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do', 'eiusmod tempor incididunt ut labore et dolore magna aliqua.', '', '' ); $this->assertEqual($expected, $result); $text = 'Lorem ipsum dolor sit amet, <b>consectetur</b> adipisicing elit, sed do <span>eiusmod tempor</span> incididunt ut labore et dolore magna aliqua.'; $this->Controller->EmailTest->sendAs = 'html'; $result = $this->Controller->EmailTest->send($text); $expected = array( $text, '', '' ); $this->assertEqual($expected, $result); }
testSendMessage method @access public @return void
testSendMessage
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function testFormatAddressAliases() { $result = $this->Controller->EmailTest->formatAddress('[email protected]'); $this->assertEqual($result, '[email protected]'); $result = $this->Controller->EmailTest->formatAddress('alias <[email protected]>'); $this->assertEqual($result, 'alias <[email protected]>'); $result = $this->Controller->EmailTest->formatAddress('alias<[email protected]>'); $this->assertEqual($result, 'alias <[email protected]>'); $result = $this->Controller->EmailTest->formatAddress('[email protected]'); $this->assertEqual($result, '[email protected]'); $result = $this->Controller->EmailTest->formatAddress('<[email protected]>'); $this->assertEqual($result, '<[email protected]>'); $result = $this->Controller->EmailTest->formatAddress('[email protected]', true); $this->assertEqual($result, '<[email protected]>'); $result = $this->Controller->EmailTest->formatAddress('<[email protected]>', true); $this->assertEqual($result, '<[email protected]>'); $result = $this->Controller->EmailTest->formatAddress('alias name <[email protected]>', true); $this->assertEqual($result, '<[email protected]>'); }
Test that _formatName doesn't jack up email addresses with alias parts. @return void
testFormatAddressAliases
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/email.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/email.test.php
MIT
function __construct($params = array()) { foreach ($params as $key => $val) { $this->{$key} = $val; } parent::__construct(); }
construct method @param array $params @access private @return void
__construct
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function destination() { $this->viewPath = 'posts'; $this->render('index'); }
test method for ajax redirection @return void
destination
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function param_method($one = null, $two = null) { echo "one: $one two: $two"; $this->autoRender = false; }
test method for ajax redirection + parameter parsing @return void
param_method
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function ajax2_layout() { if ($this->autoLayout) { $this->layout = 'ajax2'; } $this->destination(); }
test method for testing layout rendering when isAjax() @return void
ajax2_layout
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function __construct($params = array()) { foreach ($params as $key => $val) { $this->{$key} = $val; } parent::__construct(); }
construct method @param array $params @access private @return void
__construct
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function beforeFilter() { $this->RequestHandler->enabled = false; }
beforeFilter method @return void @access public
beforeFilter
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function _init() { $this->Controller = new RequestHandlerTestController(array('components' => array('RequestHandler'))); $this->Controller->constructClasses(); $this->RequestHandler =& $this->Controller->RequestHandler; }
init method @access protected @return void
_init
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function endTest() { unset($this->RequestHandler); unset($this->Controller); if (!headers_sent()) { header('Content-type: text/html'); //reset content type. } App::build(); }
endTest method @access public @return void
endTest
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testInitializeCallback() { $this->assertNull($this->RequestHandler->ext); $this->_init(); $this->Controller->params['url']['ext'] = 'rss'; $this->RequestHandler->initialize($this->Controller); $this->assertEqual($this->RequestHandler->ext, 'rss'); $settings = array( 'ajaxLayout' => 'test_ajax' ); $this->RequestHandler->initialize($this->Controller, $settings); $this->assertEqual($this->RequestHandler->ajaxLayout, 'test_ajax'); }
testInitializeCallback method @access public @return void
testInitializeCallback
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testDisabling() { $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; $this->_init(); $this->Controller->Component->initialize($this->Controller); $this->Controller->beforeFilter(); $this->Controller->Component->startup($this->Controller); $this->assertEqual($this->Controller->params, array('isAjax' => true)); $this->Controller = new RequestHandlerTestDisabledController(array('components' => array('RequestHandler'))); $this->Controller->constructClasses(); $this->Controller->Component->initialize($this->Controller); $this->Controller->beforeFilter(); $this->Controller->Component->startup($this->Controller); $this->assertEqual($this->Controller->params, array()); unset($_SERVER['HTTP_X_REQUESTED_WITH']); }
testDisabling method @access public @return void
testDisabling
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testAutoResponseType() { $this->Controller->ext = '.thtml'; $this->Controller->params['url']['ext'] = 'rss'; $this->RequestHandler->initialize($this->Controller); $this->RequestHandler->startup($this->Controller); $this->assertEqual($this->Controller->ext, '.ctp'); }
testAutoResponseType method @access public @return void
testAutoResponseType
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testAutoAjaxLayout() { $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; $this->RequestHandler->startup($this->Controller); $this->assertTrue($this->Controller->layout, $this->RequestHandler->ajaxLayout); $this->_init(); $this->Controller->params['url']['ext'] = 'js'; $this->RequestHandler->initialize($this->Controller); $this->RequestHandler->startup($this->Controller); $this->assertNotEqual($this->Controller->layout, 'ajax'); unset($_SERVER['HTTP_X_REQUESTED_WITH']); }
testAutoAjaxLayout method @access public @return void
testAutoAjaxLayout
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testStartupCallback() { $_SERVER['REQUEST_METHOD'] = 'PUT'; $_SERVER['CONTENT_TYPE'] = 'application/xml'; $this->RequestHandler->startup($this->Controller); $this->assertTrue(is_array($this->Controller->data)); $this->assertFalse(is_object($this->Controller->data)); }
testStartupCallback method @access public @return void
testStartupCallback
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testNonAjaxRedirect() { $this->RequestHandler->initialize($this->Controller); $this->RequestHandler->startup($this->Controller); $this->assertNull($this->RequestHandler->beforeRedirect($this->Controller, '/')); }
testNonAjaxRedirect method @access public @return void
testNonAjaxRedirect
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testRenderAs() { $this->assertFalse(in_array('Xml', $this->Controller->helpers)); $this->RequestHandler->renderAs($this->Controller, 'xml'); $this->assertTrue(in_array('Xml', $this->Controller->helpers)); $this->Controller->viewPath = 'request_handler_test\\xml'; $this->RequestHandler->renderAs($this->Controller, 'js'); $this->assertEqual($this->Controller->viewPath, 'request_handler_test' . DS . 'js'); }
testRenderAs method @access public @return void
testRenderAs
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testRespondAs() { $RequestHandler = new NoStopRequestHandler(); $RequestHandler->expectAt(0, '_header', array('Content-Type: application/json')); $RequestHandler->expectAt(1, '_header', array('Content-Type: text/xml')); $result = $RequestHandler->respondAs('json'); $this->assertTrue($result); $result = $RequestHandler->respondAs('text/xml'); $this->assertTrue($result); }
test that respondAs works as expected. @return void
testRespondAs
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testRespondAsWithAttachment() { $RequestHandler = new NoStopRequestHandler(); $RequestHandler->expectAt(0, '_header', array('Content-Disposition: attachment; filename="myfile.xml"')); $RequestHandler->expectAt(1, '_header', array('Content-Type: text/xml')); $result = $RequestHandler->respondAs('xml', array('attachment' => 'myfile.xml')); $this->assertTrue($result); }
test that attachment headers work with respondAs @return void
testRespondAsWithAttachment
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testRenderAsCalledTwice() { $this->RequestHandler->renderAs($this->Controller, 'xml'); $this->assertEqual($this->Controller->viewPath, 'request_handler_test' . DS . 'xml'); $this->assertEqual($this->Controller->layoutPath, 'xml'); $this->assertTrue(in_array('Xml', $this->Controller->helpers)); $this->RequestHandler->renderAs($this->Controller, 'js'); $this->assertEqual($this->Controller->viewPath, 'request_handler_test' . DS . 'js'); $this->assertEqual($this->Controller->layoutPath, 'js'); $this->assertTrue(in_array('Js', $this->Controller->helpers)); }
test that calling renderAs() more than once continues to work. @link #6466 @return void
testRenderAsCalledTwice
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testRequestClientTypes() { $this->assertFalse($this->RequestHandler->isFlash()); $_SERVER['HTTP_USER_AGENT'] = 'Shockwave Flash'; $this->assertTrue($this->RequestHandler->isFlash()); unset($_SERVER['HTTP_USER_AGENT'], $_SERVER['HTTP_X_REQUESTED_WITH']); $this->assertFalse($this->RequestHandler->isAjax()); $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; $_SERVER['HTTP_X_PROTOTYPE_VERSION'] = '1.5'; $this->assertTrue($this->RequestHandler->isAjax()); $this->assertEqual($this->RequestHandler->getAjaxVersion(), '1.5'); unset($_SERVER['HTTP_X_REQUESTED_WITH'], $_SERVER['HTTP_X_PROTOTYPE_VERSION']); $this->assertFalse($this->RequestHandler->isAjax()); $this->assertFalse($this->RequestHandler->getAjaxVersion()); }
testRequestClientTypes method @access public @return void
testRequestClientTypes
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testFlashDetection() { $_agent = env('HTTP_USER_AGENT'); $_SERVER['HTTP_USER_AGENT'] = 'Shockwave Flash'; $this->assertTrue($this->RequestHandler->isFlash()); $_SERVER['HTTP_USER_AGENT'] = 'Adobe Flash'; $this->assertTrue($this->RequestHandler->isFlash()); $_SERVER['HTTP_USER_AGENT'] = 'Adobe Flash Player 9'; $this->assertTrue($this->RequestHandler->isFlash()); $_SERVER['HTTP_USER_AGENT'] = 'Adobe Flash Player 10'; $this->assertTrue($this->RequestHandler->isFlash()); $_SERVER['HTTP_USER_AGENT'] = 'Shock Flash'; $this->assertFalse($this->RequestHandler->isFlash()); $_SERVER['HTTP_USER_AGENT'] = $_agent; }
Tests the detection of various Flash versions @access public @return void
testFlashDetection
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT
function testRequestContentTypes() { $_SERVER['REQUEST_METHOD'] = 'GET'; $this->assertNull($this->RequestHandler->requestedWith()); $_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['CONTENT_TYPE'] = 'application/json'; $this->assertEqual($this->RequestHandler->requestedWith(), 'json'); $result = $this->RequestHandler->requestedWith(array('json', 'xml')); $this->assertEqual($result, 'json'); $result =$this->RequestHandler->requestedWith(array('rss', 'atom')); $this->assertFalse($result); $_SERVER['HTTP_ACCEPT'] = 'text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,*/*'; $this->_init(); $this->assertTrue($this->RequestHandler->isXml()); $this->assertFalse($this->RequestHandler->isAtom()); $this->assertFalse($this->RequestHandler->isRSS()); $_SERVER['HTTP_ACCEPT'] = 'application/atom+xml,text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,*/*'; $this->_init(); $this->assertTrue($this->RequestHandler->isAtom()); $this->assertFalse($this->RequestHandler->isRSS()); $_SERVER['HTTP_ACCEPT'] = 'application/rss+xml,text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,*/*'; $this->_init(); $this->assertFalse($this->RequestHandler->isAtom()); $this->assertTrue($this->RequestHandler->isRSS()); $this->assertFalse($this->RequestHandler->isWap()); $_SERVER['HTTP_ACCEPT'] = 'text/vnd.wap.wml,text/html,text/plain,image/png,*/*'; $this->_init(); $this->assertTrue($this->RequestHandler->isWap()); $_SERVER['HTTP_ACCEPT'] = 'application/rss+xml ;q=0.9 , text/xml, application/xml,application/xhtml+xml'; $this->_init(); $this->assertFalse($this->RequestHandler->isAtom()); $this->assertTrue($this->RequestHandler->isRSS()); }
testRequestContentTypes method @access public @return void
testRequestContentTypes
php
Datawalke/Coordino
cake/tests/cases/libs/controller/components/request_handler.test.php
https://github.com/Datawalke/Coordino/blob/master/cake/tests/cases/libs/controller/components/request_handler.test.php
MIT