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


PHP PHPUnit_Framework_MockObject_MockObject::method方法代码示例

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


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

示例1: testCheckConnection

 public function testCheckConnection()
 {
     $map = [['a', 'b', 'c', 'd'], ['e', 'f', 'g', 'h']];
     $this->xmlRpcClient->method('call')->willReturnMap($map);
     $connection = new Connection($this->xmlRpcClient);
     $this->assertInternalType('int', $connection->checkConnection());
 }
开发者ID:HEXA-UA,项目名称:supervisor-manager,代码行数:7,代码来源:ConnectionTest.php

示例2: setUp

 protected function setUp()
 {
     $grammar = new PostgresGrammar();
     $this->connection = $this->createMock(PostgresConnection::class);
     $this->connection->method('getSchemaGrammar')->willReturn($grammar);
     $this->builder = new PostgresBuilder($this->connection);
 }
开发者ID:yurykabanov,项目名称:laravel-postgres-ext,代码行数:7,代码来源:PostgresBuilderTest.php

示例3: test_behat_command_added_to_config_if_phpunit_is_installed

 public function test_behat_command_added_to_config_if_phpunit_is_installed()
 {
     $this->packageHelper->method('hasPackage')->willReturnMap([['behat/behat', null, $this->input, $this->output, true]]);
     $this->questionHelper->method('confirmRunBehat')->willReturn(true);
     $actual = $this->sut->createConfig($this->input, $this->output);
     self::assertContains('vendor/bin/behat', $actual->getScript());
 }
开发者ID:quickstrap,项目名称:quickstrap,代码行数:7,代码来源:ConfigBuilderTest.php

示例4: testItDisplaysAConfirmationMessage

 public function testItDisplaysAConfirmationMessage()
 {
     $expectedMessage = 'Status of product "test": enabled';
     $this->mockOutput->expects($this->once())->method('writeln')->with('<info>' . $expectedMessage . '</info>');
     $this->mockInput->method('getArgument')->willReturn('test');
     $this->command->run($this->mockInput, $this->mockOutput);
 }
开发者ID:Vinai,项目名称:MM15PL_ProductStatus,代码行数:7,代码来源:EnableProductCommandTest.php

示例5: setUp

 /**
  * @see \PHPUnit_Framework_TestCase::setUp()
  */
 protected function setUp()
 {
     $repositories = $this->getMockBuilder(RepositoryService::class)->disableOriginalConstructor()->getMock();
     $this->services = $this->getMockBuilder(ServiceLocatorInterface::class)->getMock();
     $this->services->method('get')->will($this->returnValueMap([['repositories', $repositories]]));
     $this->subscriber = new RepositoryEventsSubscriber($this->services);
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:10,代码来源:RepositoryEventsSubscriberTest.php

示例6: testExecute

 /**
  * @param array $options
  * @param int $expectedPersistCount
  * @dataProvider executeDataProvider
  */
 public function testExecute(array $options, $expectedPersistCount, $exceptionMessage)
 {
     $em = $this->getMockBuilder('\\Doctrine\\Common\\Persistence\\ObjectManager')->disableOriginalConstructor()->getMock();
     $em->expects($this->exactly($expectedPersistCount))->method('persist')->will($this->returnCallback(function ($object) use($options) {
         if ('Oro\\Bundle\\CalendarBundle\\Entity\\CalendarEvent' === get_class($object)) {
             $this->assertEquals($options[CreateCalendarEventAction::OPTION_KEY_TITLE], $object->getTitle());
             $this->assertEquals($options[CreateCalendarEventAction::OPTION_KEY_START], $object->getStart());
             if (isset($options[CreateCalendarEventAction::OPTION_KEY_END])) {
                 $this->assertEquals($options[CreateCalendarEventAction::OPTION_KEY_END], $object->getEnd());
             } elseif (isset($options[CreateCalendarEventAction::OPTION_KEY_DURATION])) {
                 $this->assertEquals($options[CreateCalendarEventAction::OPTION_KEY_START]->modify('+ ' . $options[CreateCalendarEventAction::OPTION_KEY_DURATION]), $object->getEnd());
             } else {
                 $this->assertEquals($options[CreateCalendarEventAction::OPTION_KEY_START]->modify('+ 1 hour'), $object->getEnd());
             }
         } elseif ('Oro\\Bundle\\ReminderBundle\\Entity\\Reminder' === get_class($object)) {
             $this->assertEquals($options[CreateCalendarEventAction::OPTION_KEY_TITLE], $object->getSubject());
         } else {
             throw new \InvalidArgumentException(sprintf('Persistent object must be "%s" or "%s"', self::CLASS_NAME_CALENDAR_EVENT, self::CLASS_NAME_REMINDER));
         }
     }));
     $this->registry->method('getManagerForClass')->willReturn($em);
     if ($exceptionMessage) {
         $this->setExpectedException('\\Oro\\Bundle\\WorkflowBundle\\Exception\\InvalidParameterException', $exceptionMessage);
     }
     $action = $this->getAction();
     $context = new ItemStub([]);
     $action->initialize($options);
     $action->execute($context);
 }
开发者ID:startupz,项目名称:platform-1,代码行数:34,代码来源:CreateCalendarEventActionTest.php

示例7: setSkeletonToReturn

 /**
  * @param mixed $value
  */
 private function setSkeletonToReturn($value)
 {
     if (is_string($value)) {
         $value = new $value();
     }
     $this->skeleton->method('get')->willReturn($value);
 }
开发者ID:oktopost,项目名称:skeleton,代码行数:10,代码来源:ConstructorConnectorTest.php

示例8: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->setCollectionFactory = $this->getMock('Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Set\\CollectionFactory', ['create'], [], '', false);
     $this->setCollection = $this->getMock('Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Set\\Collection', ['setEntityTypeFilter'], [], '', false);
     $this->setCollectionFactory->expects($this->any())->method('create')->will($this->returnValue($this->setCollection));
     $this->setCollection->expects($this->any())->method('setEntityTypeFilter')->will($this->returnValue([]));
     $this->attrCollectionFactory = $this->getMock('Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\CollectionFactory', ['create', 'addFieldToFilter'], [], '', false);
     $this->attrCollectionFactory->expects($this->any())->method('create')->will($this->returnSelf());
     $this->attrCollectionFactory->expects($this->any())->method('addFieldToFilter')->willReturn([]);
     $this->entityModel = $this->getMock('Magento\\CatalogImportExport\\Model\\Import\\Product', ['getErrorAggregator', 'getNewSku', 'getOldSku', 'getNextBunch', 'isRowAllowedToImport', 'getRowScope'], [], '', false);
     $this->entityModel->method('getErrorAggregator')->willReturn($this->getErrorAggregatorObject());
     $this->params = [0 => $this->entityModel, 1 => 'grouped'];
     $this->links = $this->getMock('Magento\\GroupedImportExport\\Model\\Import\\Product\\Type\\Grouped\\Links', [], [], '', false);
     $entityAttributes = [['attribute_set_name' => 'attribute_id', 'attribute_id' => 'attributeSetName']];
     $this->connection = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', ['select', 'fetchAll', 'fetchPairs', 'joinLeft', 'insertOnDuplicate', 'delete', 'quoteInto'], [], '', false);
     $this->select = $this->getMock('Magento\\Framework\\DB\\Select', ['from', 'where', 'joinLeft', 'getConnection'], [], '', false);
     $this->select->expects($this->any())->method('from')->will($this->returnSelf());
     $this->select->expects($this->any())->method('where')->will($this->returnSelf());
     $this->select->expects($this->any())->method('joinLeft')->will($this->returnSelf());
     $this->connection->expects($this->any())->method('select')->will($this->returnValue($this->select));
     $connectionMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
     $connectionMock->expects($this->any())->method('quoteInto')->will($this->returnValue('query'));
     $this->select->expects($this->any())->method('getConnection')->willReturn($connectionMock);
     $this->connection->expects($this->any())->method('insertOnDuplicate')->willReturnSelf();
     $this->connection->expects($this->any())->method('delete')->willReturnSelf();
     $this->connection->expects($this->any())->method('quoteInto')->willReturn('');
     $this->connection->expects($this->any())->method('fetchAll')->will($this->returnValue($entityAttributes));
     $this->resource = $this->getMock('\\Magento\\Framework\\App\\ResourceConnection', ['getConnection', 'getTableName'], [], '', false);
     $this->resource->expects($this->any())->method('getConnection')->will($this->returnValue($this->connection));
     $this->resource->expects($this->any())->method('getTableName')->will($this->returnValue('tableName'));
     $this->grouped = $this->objectManagerHelper->getObject('Magento\\GroupedImportExport\\Model\\Import\\Product\\Type\\Grouped', ['attrSetColFac' => $this->setCollectionFactory, 'prodAttrColFac' => $this->attrCollectionFactory, 'resource' => $this->resource, 'params' => $this->params, 'links' => $this->links]);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:33,代码来源:GroupedTest.php

示例9: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->entityModel = $this->getMock('Magento\\CatalogImportExport\\Model\\Import\\Product', ['getErrorAggregator', 'getBehavior', 'getNewSku', 'getNextBunch', 'isRowAllowedToImport', 'getRowScope', 'getConnection'], [], '', false);
     $this->entityModel->method('getErrorAggregator')->willReturn($this->getErrorAggregatorObject());
     $this->connection = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', ['select', 'fetchAll', 'fetchPairs', 'joinLeft', 'insertOnDuplicate', 'delete', 'quoteInto', 'fetchAssoc'], [], '', false);
     $this->select = $this->getMock('Magento\\Framework\\DB\\Select', [], [], '', false);
     $this->select->expects($this->any())->method('from')->will($this->returnSelf());
     $this->select->expects($this->any())->method('where')->will($this->returnSelf());
     $this->select->expects($this->any())->method('joinLeft')->will($this->returnSelf());
     $this->select->expects($this->any())->method('getConnection')->willReturn($this->connection);
     $this->connection->expects($this->any())->method('select')->will($this->returnValue($this->select));
     $this->initFetchAllCalls();
     $this->connection->expects($this->any())->method('insertOnDuplicate')->willReturnSelf();
     $this->connection->expects($this->any())->method('delete')->willReturnSelf();
     $this->connection->expects($this->any())->method('quoteInto')->willReturn('');
     $this->resource = $this->getMock('Magento\\Framework\\App\\ResourceConnection', ['getConnection', 'getTableName'], [], '', false);
     $this->resource->expects($this->any())->method('getConnection')->will($this->returnValue($this->connection));
     $this->resource->expects($this->any())->method('getTableName')->will($this->returnValue('tableName'));
     $this->attrSetColFac = $this->getMock('Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Set\\CollectionFactory', ['create'], [], '', false);
     $this->setCollection = $this->getMock('Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Set\\Collection', ['setEntityTypeFilter'], [], '', false);
     $this->attrSetColFac->expects($this->any())->method('create')->will($this->returnValue($this->setCollection));
     $this->setCollection->expects($this->any())->method('setEntityTypeFilter')->will($this->returnValue([]));
     $this->prodAttrColFac = $this->getMock('Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\CollectionFactory', ['create'], [], '', false);
     $attrCollection = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\Collection', [], [], '', false);
     $attrCollection->expects($this->any())->method('addFieldToFilter')->willReturn([]);
     $this->prodAttrColFac->expects($this->any())->method('create')->will($this->returnValue($attrCollection));
     $this->params = [0 => $this->entityModel, 1 => 'bundle'];
     $this->bundle = $this->objectManagerHelper->getObject('Magento\\BundleImportExport\\Model\\Import\\Product\\Type\\Bundle', ['attrSetColFac' => $this->attrSetColFac, 'prodAttrColFac' => $this->prodAttrColFac, 'resource' => $this->resource, 'params' => $this->params]);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:30,代码来源:BundleTest.php

示例10: testWriteNotTimeToCleanYet

 public function testWriteNotTimeToCleanYet()
 {
     $this->db->method('fetchValue')->willReturn(5);
     $this->db->expects($this->never())->method('exec')->with($this->stringStartsWith('DELETE'));
     $this->dbHandler->setCleanProbability(100);
     $this->dbHandler->handle(self::$testRecord);
 }
开发者ID:starweb,项目名称:starlit-db,代码行数:7,代码来源:DbHandlerTest.php

示例11: testExpandDependenciesNoVariantsOrStaticDependencies

 /**
  * Tests expandDependencies() when no variants exist and there are no static
  * (non-variant) dependencies.
  *
  * @covers ::expandDependencies
  */
 public function testExpandDependenciesNoVariantsOrStaticDependencies()
 {
     $this->query->method('execute')->willReturn([]);
     $dependencies = ['required' => ['d6_node:*', 'd6_node_revision:*']];
     $dependencies = $this->storage->expandDependencies($dependencies);
     $this->assertSame([], $dependencies['required']);
 }
开发者ID:scratch,项目名称:gai,代码行数:13,代码来源:MigrationStorageTest.php

示例12: setUp

 protected function setUp()
 {
     $objectManager = new ObjectManager($this);
     $this->connection = $this->getMockBuilder('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface')->disableOriginalConstructor()->getMock();
     $this->connection->expects($this->any())->method('quoteInto')->willReturnCallback(function ($query, $expression) {
         return str_replace('?', $expression, $query);
     });
     $this->resource = $this->getMockBuilder('\\Magento\\Framework\\App\\ResourceConnection')->disableOriginalConstructor()->getMock();
     $this->resource->method('getTableName')->willReturnCallback(function ($table) {
         return 'prefix_' . $table;
     });
     $this->resource->expects($this->any())->method('getConnection')->willReturn($this->connection);
     $this->website = $this->getMockBuilder('\\Magento\\Store\\Api\\Data\\WebsiteInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->website->expects($this->any())->method('getId')->willReturn(self::WEBSITE_ID);
     $this->store = $this->getMockBuilder('\\Magento\\Store\\Api\\Data\\StoreInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->store->expects($this->any())->method('getId')->willReturn(self::STORE_ID);
     $this->storeManager = $this->getMockBuilder('\\Magento\\Store\\Model\\StoreManagerInterface')->disableOriginalConstructor()->getMock();
     $this->storeManager->expects($this->any())->method('getWebsite')->willReturn($this->website);
     $this->storeManager->expects($this->any())->method('getStore')->willReturn($this->store);
     $this->attributeCollection = $this->getMockBuilder('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\Collection')->disableOriginalConstructor()->getMock();
     $attributeCollectionFactory = $this->getMockBuilder('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\CollectionFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $attributeCollectionFactory->expects($this->once())->method('create')->willReturn($this->attributeCollection);
     $this->target = $objectManager->getObject('\\Magento\\CatalogSearch\\Model\\Search\\TableMapper', ['resource' => $this->resource, 'storeManager' => $this->storeManager, 'attributeCollectionFactory' => $attributeCollectionFactory]);
     $this->select = $this->getMockBuilder('\\Magento\\Framework\\DB\\Select')->disableOriginalConstructor()->getMock();
     $this->request = $this->getMockBuilder('\\Magento\\Framework\\Search\\RequestInterface')->disableOriginalConstructor()->getMock();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:26,代码来源:TableMapperTest.php

示例13: getMigration

 /**
  * Retrieves a mocked migration.
  *
  * @return \Drupal\migrate\Entity\MigrationInterface|\PHPUnit_Framework_MockObject_MockObject
  *   The mocked migration.
  */
 protected function getMigration()
 {
     $this->migrationConfiguration += ['migrationClass' => 'Drupal\\migrate\\Entity\\Migration'];
     $this->idMap = $this->getMock('Drupal\\migrate\\Plugin\\MigrateIdMapInterface');
     $this->idMap->method('getQualifiedMapTableName')->willReturn('test_map');
     $migration = $this->getMockBuilder($this->migrationConfiguration['migrationClass'])->disableOriginalConstructor()->getMock();
     $migration->method('checkRequirements')->willReturn(TRUE);
     $migration->method('getIdMap')->willReturn($this->idMap);
     // We need the state to be toggled throughout the test so we store the value
     // on the test class and use a return callback.
     $migration->expects($this->any())->method('getStatus')->willReturnCallback(function () {
         return $this->migrationStatus;
     });
     $migration->expects($this->any())->method('setStatus')->willReturnCallback(function ($status) {
         $this->migrationStatus = $status;
     });
     $migration->method('getMigrationDependencies')->willReturn(['required' => [], 'optional' => []]);
     $configuration =& $this->migrationConfiguration;
     $migration->method('get')->willReturnCallback(function ($argument) use(&$configuration) {
         return isset($configuration[$argument]) ? $configuration[$argument] : '';
     });
     $migration->method('set')->willReturnCallback(function ($argument, $value) use(&$configuration) {
         $configuration[$argument] = $value;
     });
     $migration->method('id')->willReturn($configuration['id']);
     return $migration;
 }
开发者ID:isramv,项目名称:camp-gdl,代码行数:33,代码来源:MigrateTestCase.php

示例14: testItDisplaysTheStatusForAllMatchingProducts

 public function testItDisplaysTheStatusForAllMatchingProducts()
 {
     $this->mockInput->method('getArgument')->with('sku')->willReturn('TEST');
     $this->mockProductStatusAdapter->method('getProductStatusMatchingSku')->willReturn(['TEST1' => ProductStatusAdapterInterface::ENABLED, 'TEST2' => ProductStatusAdapterInterface::DISABLED, 'TEST3' => ProductStatusAdapterInterface::ENABLED]);
     $this->mockOutput->method('writeln')->withConsecutive(['<info>TEST1: enabled</info>'], ['<info>TEST2: disabled</info>'], ['<info>TEST3: enabled</info>']);
     $this->command->run($this->mockInput, $this->mockOutput);
 }
开发者ID:nhp,项目名称:MageTitans_ProductStatus,代码行数:7,代码来源:ShowProductStatusCommandTest.php

示例15: testItDisplaysAConfirmationMessageIfThereWasNoException

 public function testItDisplaysAConfirmationMessageIfThereWasNoException()
 {
     $expectedMessage = 'Status of product "test": ' . ProductStatusAdapterInterface::DISABLED;
     $this->mockOutput->expects($this->once())->method('writeln')->with($this->stringStartsWith('<info>' . $expectedMessage));
     $this->mockInput->method('getArgument')->willReturn('test');
     $this->command->run($this->mockInput, $this->mockOutput);
 }
开发者ID:Vinai,项目名称:MM15PL_ProductStatus,代码行数:7,代码来源:DisableProductCommandTest.php


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