本文整理汇总了PHP中PHPUnit_Framework_MockObject_MockObject::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_MockObject_MockObject::getId方法的具体用法?PHP PHPUnit_Framework_MockObject_MockObject::getId怎么用?PHP PHPUnit_Framework_MockObject_MockObject::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_MockObject_MockObject
的用法示例。
在下文中一共展示了PHPUnit_Framework_MockObject_MockObject::getId方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveModelAndFailOnUpdate
/**
* Callback for save method in mocked model
*
* @throws Magento_Exception
*/
public function saveModelAndFailOnUpdate()
{
if (!$this->_model->getId()) {
$this->saveModelSuccessfully();
} else {
throw new Magento_Exception('Synthetic model update failure.');
}
}
示例2: saveModelAndFailOnUpdate
/**
* Callback for save method in mocked model
*
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function saveModelAndFailOnUpdate()
{
if (!$this->_model->getId()) {
$this->saveModelSuccessfully();
} else {
throw new \Magento\Framework\Exception\LocalizedException(__('Synthetic model update failure.'));
}
}
示例3: testSetAndGetId
public function testSetAndGetId()
{
$this->mockModel();
$testId = 9999;
$this->model->setId($testId);
$this->assertEquals($testId, $this->model->getId());
}
示例4: createSampleModel
/**
* @param \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $product
* @param array $modelData
* @return \Magento\Downloadable\Model\Sample|\PHPUnit_Framework_MockObject_MockObject
*/
private function createSampleModel($product, array $modelData)
{
$sample = $this->getMockBuilder('\\Magento\\Downloadable\\Model\\Sample')->disableOriginalConstructor()->setMethods(['setData', 'setSampleType', 'setProductId', 'setStoreId', 'setProductWebsiteIds', 'setNumberOfDownloads', 'setSampleUrl', 'setLinkFile', 'setSampleFile', 'save'])->getMock();
$sample->expects($this->once())->method('setData')->with($modelData)->will($this->returnSelf());
$sample->expects($this->once())->method('setSampleType')->with($modelData['type'])->will($this->returnSelf());
$sample->expects($this->once())->method('setProductId')->with($product->getId())->will($this->returnSelf());
$sample->expects($this->once())->method('setStoreId')->with($product->getStoreId())->will($this->returnSelf());
return $sample;
}
示例5: testGetInfo
/**
* @covers ::getInfo
*/
public function testGetInfo()
{
$token_info = array('types' => array('foo' => array('name' => $this->randomMachineName())));
$this->language->expects($this->atLeastOnce())->method('getId')->will($this->returnValue($this->randomMachineName()));
$this->languageManager->expects($this->once())->method('getCurrentLanguage')->with(LanguageInterface::TYPE_CONTENT)->will($this->returnValue($this->language));
// The persistent cache must only be hit once, after which the info is
// cached statically.
$this->cache->expects($this->once())->method('get');
$this->cache->expects($this->once())->method('set')->with('token_info:' . $this->language->getId(), $token_info);
$this->moduleHandler->expects($this->once())->method('invokeAll')->with('token_info')->will($this->returnValue($token_info));
$this->moduleHandler->expects($this->once())->method('alter')->with('token_info', $token_info);
// Get the information for the first time. The cache should be checked, the
// hooks invoked, and the info should be set to the cache should.
$this->token->getInfo();
// Get the information for the second time. The data must be returned from
// the static cache, so the persistent cache must not be accessed and the
// hooks must not be invoked.
$this->token->getInfo();
}
示例6: testExecuteUrlKey
/**
* @param bool $isChangedUrlKey
* @param bool $isChangedVisibility
* @param bool $isChangedWebsites
* @param bool $isChangedCategories
* @param bool $visibilityResult
* @param int $expectedDeleteCount
* @param int $expectedReplaceCount
*
* @dataProvider testUrlKeyDataProvider
*/
public function testExecuteUrlKey($isChangedUrlKey, $isChangedVisibility, $isChangedWebsites, $isChangedCategories, $visibilityResult, $expectedDeleteCount, $expectedReplaceCount)
{
$this->product->expects($this->any())->method('getStoreId')->will($this->returnValue(12));
$this->product->expects($this->any())->method('dataHasChangedFor')->will($this->returnValueMap([['visibility', $isChangedVisibility], ['url_key', $isChangedUrlKey]]));
$this->product->expects($this->any())->method('getIsChangedWebsites')->will($this->returnValue($isChangedWebsites));
$this->product->expects($this->any())->method('getIsChangedCategories')->will($this->returnValue($isChangedCategories));
$this->urlPersist->expects($this->exactly($expectedDeleteCount))->method('deleteByData')->with([UrlRewrite::ENTITY_ID => $this->product->getId(), UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE, UrlRewrite::REDIRECT_TYPE => 0, UrlRewrite::STORE_ID => $this->product->getStoreId()]);
$this->product->expects($this->any())->method('isVisibleInSiteVisibility')->will($this->returnValue($visibilityResult));
$this->urlPersist->expects($this->exactly($expectedReplaceCount))->method('replace')->with([3 => 'rewrite']);
$this->model->execute($this->observer);
}
示例7: getTitle
/**
* @return \Magento\Framework\Phrase|string
*/
protected function getTitle()
{
return $this->blockMock->getId() ? $this->blockMock->getTitle() : __('New Block');
}
示例8: testSendTransactional
public function testSendTransactional()
{
$this->_model->sendTransactional('customer_create_account_email_template', array('name' => 'Sender Name', 'email' => 'sender@example.com'), 'recipient@example.com', 'Recipient Name');
$this->assertEquals('customer_create_account_email_template', $this->_model->getId());
$this->assertTrue($this->_model->getSentSuccess());
}
示例9: testGetId
/**
* Test the getId() method from the Chromosome class
*
* @uses \bcGen\MainBundle\Entity\Chromosome::getId()
*/
public function testGetId()
{
echo "\n********************Test GetId()*********************************************************\n";
$this->stubedChromosome->method('getId')->willReturn(1);
$this->assertEquals(1, $this->stubedChromosome->getId());
}
示例10: testLoad
/**
* @param $loadId
* @param $expectedId
* @dataProvider loadDataProvider
*/
public function testLoad($loadId, $expectedId)
{
$this->model->load($loadId);
$this->assertEquals($expectedId, $this->model->getId());
}
示例11: getTitle
/**
* @return \Magento\Framework\Phrase|string
*/
protected function getTitle()
{
return $this->pageMock->getId() ? $this->pageMock->getTitle() : __('New Page');
}
示例12: testEntityMethods
public function testEntityMethods()
{
$this->assertNull($this->entity->getId());
}
示例13: testSetId
/**
* @param \PHPUnit_Framework_MockObject_MockObject $criteria
* @return \PHPUnit_Framework_MockObject_MockObject
*
* @depends testImplementCriteriaInterface
* @covers Sellsy\Criteria\Generic\GetOneCriteria::setId
*/
public function testSetId(\PHPUnit_Framework_MockObject_MockObject $criteria)
{
$criteria->setId(12);
$this->assertEquals(12, $criteria->getId());
return $criteria;
}