当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPUnit_Framework_MockObject_MockObject::save方法代码示例

本文整理汇总了PHP中PHPUnit_Framework_MockObject_MockObject::save方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_MockObject_MockObject::save方法的具体用法?PHP PHPUnit_Framework_MockObject_MockObject::save怎么用?PHP PHPUnit_Framework_MockObject_MockObject::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPUnit_Framework_MockObject_MockObject的用法示例。


在下文中一共展示了PHPUnit_Framework_MockObject_MockObject::save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testSaveWithException

 public function testSaveWithException()
 {
     $exceptionMessage = 'Some Message';
     $this->bookmarkResourceMock->expects($this->once())->method('save')->with($this->bookmarkMock)->willThrowException(new \Exception($exceptionMessage));
     $this->setExpectedException('Magento\\Framework\\Exception\\CouldNotSaveException', __($exceptionMessage));
     $this->bookmarkRepository->save($this->bookmarkMock);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:7,代码来源:BookmarkRepositoryTest.php

示例2: testSaveWithExtra

 public function testSaveWithExtra()
 {
     $log = $this->subject->create();
     $log->setExtra(['job_ticket']);
     $this->entityManager->expects($this->once())->method('persist')->with($this->callback(function (LogInterface $value) use($log) {
         $extra = $value->getExtra();
         return $log === $value && !isset($extra['job_ticket']);
     }));
     $this->subject->save($log);
 }
开发者ID:aboutcoders,项目名称:job-bundle,代码行数:10,代码来源:LogManagerTest.php

示例3: testRequiredValidation

 /**
  * Tests required validation.
  *
  * @covers ::validate
  * @covers ::isValidationRequired
  * @covers ::setValidationRequired
  * @covers ::save
  * @covers ::preSave
  *
  * @expectedException \LogicException
  * @expectedExceptionMessage Entity validation was skipped.
  */
 public function testRequiredValidation()
 {
     $validator = $this->getMock('\\Symfony\\Component\\Validator\\ValidatorInterface');
     /** @var \Symfony\Component\Validator\ConstraintViolationList|\PHPUnit_Framework_MockObject_MockObject $empty_violation_list */
     $empty_violation_list = $this->getMockBuilder('\\Symfony\\Component\\Validator\\ConstraintViolationList')->setMethods(NULL)->getMock();
     $validator->expects($this->at(0))->method('validate')->with($this->entity->getTypedData())->will($this->returnValue($empty_violation_list));
     $this->typedDataManager->expects($this->any())->method('getValidator')->will($this->returnValue($validator));
     /** @var \Drupal\Core\Entity\EntityStorageInterface|\PHPUnit_Framework_MockObject_MockObject $storage */
     $storage = $this->getMock('\\Drupal\\Core\\Entity\\EntityStorageInterface');
     $storage->expects($this->any())->method('save')->willReturnCallback(function (ContentEntityInterface $entity) use($storage) {
         $entity->preSave($storage);
     });
     $this->entityManager->expects($this->any())->method('getStorage')->with($this->entityTypeId)->will($this->returnValue($storage));
     // Check that entities can be saved normally when validation is not
     // required.
     $this->assertFalse($this->entity->isValidationRequired());
     $this->entity->save();
     // Make validation required and check that if the entity is validated, it
     // can be saved normally.
     $this->entity->setValidationRequired(TRUE);
     $this->assertTrue($this->entity->isValidationRequired());
     $this->entity->validate();
     $this->entity->save();
     // Check that the "validated" status is reset after saving the entity and
     // that trying to save a non-validated entity when validation is required
     // results in an exception.
     $this->assertTrue($this->entity->isValidationRequired());
     $this->entity->save();
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:41,代码来源:ContentEntityBaseUnitTest.php

示例4: testSaveValidation

 /**
  * @param array $badStoreData
  *
  * @dataProvider saveValidationDataProvider
  * @magentoAppIsolation enabled
  * @magentoAppArea adminhtml
  * @magentoDbIsolation enabled
  * @expectedException \Magento\Framework\Exception\LocalizedException
  */
 public function testSaveValidation($badStoreData)
 {
     $normalStoreData = ['code' => 'test', 'website_id' => 1, 'group_id' => 1, 'name' => 'test name', 'sort_order' => 0, 'is_active' => 1];
     $data = array_merge($normalStoreData, $badStoreData);
     $this->model->setData($data);
     $this->model->save();
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:16,代码来源:StoreTest.php

示例5: testSave

 /**
  * @covers ::save
  */
 public function testSave()
 {
     $storage = $this->getMock('\\Drupal\\Core\\Entity\\EntityStorageInterface');
     $storage->expects($this->once())->method('save')->with($this->entity);
     $this->entityManager->expects($this->once())->method('getStorage')->with($this->entityTypeId)->will($this->returnValue($storage));
     $this->entity->save();
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:10,代码来源:EntityUnitTest.php


注:本文中的PHPUnit_Framework_MockObject_MockObject::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。