protected function setUp() { $this->filesystemMock = $this->getMock('Magento\\Framework\\App\\Filesystem', array(), array(), '', false, false); $this->directoryMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Read', array(), array(), '', false, false); $this->_stringMock = $this->getMock('Magento\\Framework\\Stdlib\\String', array(), array(), '', false, false); $this->_stringMock->expects($this->once())->method('upperCaseWords')->will($this->returnValue('Test/Module')); $this->filesystemMock->expects($this->once())->method('getDirectoryRead')->will($this->returnValue($this->directoryMock)); $this->_model = new \Magento\Framework\Module\Dir($this->filesystemMock, $this->_stringMock); }
public function testGetTooLongQuery() { $queryId = 123; $this->mapScopeConfig([self::XML_PATH_MAX_QUERY_LENGTH => 12]); $rawQueryText = 'This is very long search query text'; $preparedQueryText = 'This is very'; $this->stringMock->expects($this->once())->method('substr')->with($this->equalTo($rawQueryText))->will($this->returnValue($preparedQueryText)); $this->requestMock->expects($this->once())->method('getParam')->with($this->equalTo(self::QUERY_VAR_NAME))->will($this->returnValue($rawQueryText)); $this->objectManagerMock->expects($this->once())->method('create')->with($this->equalTo('Magento\\Search\\Model\\Query'))->will($this->returnValue($this->queryMock)); $this->queryMock->expects($this->once())->method('loadByQuery')->with($this->equalTo($preparedQueryText))->will($this->returnSelf()); $this->queryMock->expects($this->once())->method('getId')->will($this->returnValue($queryId)); $this->queryMock->expects($this->once())->method('setIsQueryTextExceeded')->with($this->equalTo(true))->will($this->returnSelf()); $query = $this->queryFactory->get(); $this->assertSame($this->queryMock, $query); }
public function testRenderMetadata() { $metadata = ['charset' => 'charsetValue', 'metadataName' => 'metadataValue', 'content_type' => 'content_type_value', 'x_ua_compatible' => 'x_ua_compatible_value', 'media_type' => 'media_type_value']; $metadataValueCharset = 'newCharsetValue'; $expected = '<meta charset="newCharsetValue"/>' . "\n" . '<meta name="metadataName" content="metadataValue"/>' . "\n" . '<meta http-equiv="Content-Type" content="content_type_value"/>' . "\n" . '<meta http-equiv="X-UA-Compatible" content="x_ua_compatible_value"/>' . "\n"; $this->stringMock->expects($this->at(0))->method('upperCaseWords')->with('charset', '_', '')->willReturn('Charset'); $this->pageConfigMock->expects($this->once())->method('getCharset')->willReturn($metadataValueCharset); $this->pageConfigMock->expects($this->once())->method('getMetadata')->will($this->returnValue($metadata)); $this->assertEquals($expected, $this->renderer->renderMetadata()); }
/** * @param boolean $clean * @return $this */ protected function _prepareCleanString($clean) { $cleanStringExpects = $clean ? $this->once() : $this->never(); $this->_converter->expects($cleanStringExpects)->method('cleanString')->will($this->returnValue('converted value')); return $this; }
/** * @expectedException \InvalidArgumentException * @expectedExceptionMessage Directory type 'unknown' is not recognized */ public function testGetDirModuleSubDirUnknown() { $this->_stringMock->expects($this->once())->method('upperCaseWords')->will($this->returnValue('Test/Module')); $this->_model->getDir('Test_Module', 'unknown'); }