當前位置: 首頁>>代碼示例>>PHP>>正文


PHP String::expects方法代碼示例

本文整理匯總了PHP中Magento\Framework\Stdlib\String::expects方法的典型用法代碼示例。如果您正苦於以下問題:PHP String::expects方法的具體用法?PHP String::expects怎麽用?PHP String::expects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\Stdlib\String的用法示例。


在下文中一共展示了String::expects方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUp

 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);
 }
開發者ID:,項目名稱:,代碼行數:9,代碼來源:

示例2: testGetTooLongQuery

 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);
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:15,代碼來源:QueryFactoryTest.php

示例3: testRenderMetadata

 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());
 }
開發者ID:,項目名稱:,代碼行數:10,代碼來源:

示例4: _prepareCleanString

 /**
  * @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;
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:10,代碼來源:HeaderTest.php

示例5: testGetDirModuleSubDirUnknown

 /**
  * @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');
 }
開發者ID:vasiljok,項目名稱:magento2,代碼行數:9,代碼來源:DirTest.php


注:本文中的Magento\Framework\Stdlib\String::expects方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。