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


PHP PHPUnit_Framework_MockObject_Generator类代码示例

本文整理汇总了PHP中PHPUnit_Framework_MockObject_Generator的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_MockObject_Generator类的具体用法?PHP PHPUnit_Framework_MockObject_Generator怎么用?PHP PHPUnit_Framework_MockObject_Generator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getVcsAdapterMock

 /**
  * Get VCS adapter mock
  *
  * @return object
  */
 protected static function getVcsAdapterMock()
 {
     $generator = new \PHPUnit_Framework_MockObject_Generator();
     $vcsAdapter = $generator->getMock('PreCommit\\Vcs\\Git');
     $vcsAdapter->expects(self::once())->method('getAffectedFiles')->will(self::returnValue([]));
     return $vcsAdapter;
 }
开发者ID:andkirby,项目名称:commithook,代码行数:12,代码来源:RedundantCodeTest.php

示例2: workers

 public static function workers()
 {
     $mockGenerator = new \PHPUnit_Framework_MockObject_Generator();
     $event = 'PHPExtra\\EventManager\\Event\\Event';
     $listener = $mockGenerator->getMock('PHPExtra\\EventManager\\Listener\\Listener');
     /** @var Listener $listener */
     return array(array(array(new Worker(1, $listener, 'dummy1', $event, Priority::NORMAL), new Worker(2, $listener, 'dummy2', $event, Priority::NORMAL), new Worker(3, $listener, 'dummy3', $event, Priority::NORMAL))));
 }
开发者ID:phpextra,项目名称:event-manager,代码行数:8,代码来源:WorkerQueueTest.php

示例3: getPlainMock

 /**
  * Get a plain command-object mock
  *
  * @return \Testy\Project
  */
 public static function getPlainMock()
 {
     $oMockBuilder = new \PHPUnit_Framework_MockObject_Generator();
     $oMock = $oMockBuilder->getMock('\\Testy\\Project');
     $oMock->expects(\PHPUnit_Framework_TestCase::any())->method('getName')->will(\PHPUnit_Framework_TestCase::returnValue(\Testy\CLI\Application::NAME));
     $oMock->expects(\PHPUnit_Framework_TestCase::any())->method('getProjectHash')->will(\PHPUnit_Framework_TestCase::returnValue(md5(rand())));
     return $oMock;
 }
开发者ID:hpbuniat,项目名称:testy,代码行数:13,代码来源:Project.php

示例4: getPlainMock

 /**
  * Get a plain command-object mock
  *
  * @param  string $sReturn
  *
  * @return \Testy\Util\Command
  */
 public static function getPlainMock($sReturn = '')
 {
     $oMockBuilder = new \PHPUnit_Framework_MockObject_Generator();
     $oCommandMock = $oMockBuilder->getMock('\\Testy\\Util\\Command');
     $oCommandMock->expects(\PHPUnit_Framework_TestCase::any())->method('execute')->will(\PHPUnit_Framework_TestCase::returnSelf());
     $oCommandMock->expects(\PHPUnit_Framework_TestCase::any())->method('reset')->will(\PHPUnit_Framework_TestCase::returnSelf());
     $oCommandMock->expects(\PHPUnit_Framework_TestCase::any())->method('setCommand')->will(\PHPUnit_Framework_TestCase::returnSelf());
     $oCommandMock->expects(\PHPUnit_Framework_TestCase::any())->method('get')->will(\PHPUnit_Framework_TestCase::returnValue($sReturn));
     return $oCommandMock;
 }
开发者ID:hpbuniat,项目名称:testy,代码行数:17,代码来源:Command.php

示例5: __construct

 /**
  * Constructor
  */
 public function __construct()
 {
     $mockBuilder = new \PHPUnit_Framework_MockObject_Generator();
     $this->variableProvider = $mockBuilder->getMock(VariableProviderInterface::class);
     $this->viewHelperVariableContainer = $mockBuilder->getMock(ViewHelperVariableContainer::class, ['dummy']);
     $this->viewHelperResolver = $mockBuilder->getMock(ViewHelperResolver::class, ['dummy']);
     $this->viewHelperInvoker = $mockBuilder->getMock(ViewHelperInvoker::class, ['dummy']);
     $this->templateParser = $mockBuilder->getMock(TemplateParser::class, ['dummy']);
     $this->templateCompiler = $mockBuilder->getMock(TemplateCompiler::class, ['dummy']);
     $this->templatePaths = $mockBuilder->getMock(TemplatePaths::class, ['dummy']);
     $this->cache = $mockBuilder->getMock(FluidCacheInterface::class);
 }
开发者ID:typo3,项目名称:fluid,代码行数:15,代码来源:RenderingContextFixture.php

示例6: validates_expectations

 /**
  * @test
  * @expectedExceptionMessage Pass
  **/
 public function validates_expectations()
 {
     $mockBuilder = new PHPUnit_Framework_MockObject_Generator();
     $mock = $mockBuilder->getMock('Spy');
     $mock->expects($this->once())->method('getValue')->willCallOriginal();
     try {
         $mock->getValue();
         $mock->getValue();
         $this->fail("Failed to validate expectation on the spy object");
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
     }
 }
开发者ID:Darhazer,项目名称:better-phpunit-mock-objects,代码行数:16,代码来源:CallOriginalTest.php

示例7: factory

 public static function factory($class, $params = array(), $parent = '')
 {
     $mock = \PHPUnit_Framework_MockObject_Generator::getMock($class, array(), array(), '', false);
     self::bindParameters($mock, $params);
     $mock->__mocked = $class;
     return $mock;
 }
开发者ID:BatVane,项目名称:Codeception,代码行数:7,代码来源:Stub.php

示例8: testCanInvokeMethodsOfNonExistentClass

 /**
  * @covers PHPUnit_Framework_MockObject_Generator::getMock
  */
 public function testCanInvokeMethodsOfNonExistentClass()
 {
     $className = 'X' . md5(microtime());
     $mock = $this->generator->getMock($className, ['someMethod']);
     $mock->expects($this->once())->method('someMethod');
     $this->assertNull($mock->someMethod());
 }
开发者ID:thekabal,项目名称:tki,代码行数:10,代码来源:GeneratorTest.php

示例9: testGetMockOverExistingObject

 /**
  * @covers PHPUnit_Framework_MockObject_Generator::getMockOverExistingObject
  */
 public function testGetMockOverExistingObject()
 {
     $srcObject = new ClassWithProtectedMethod();
     $this->assertEquals('real-value', $srcObject->testMethod());
     $mock = $this->generator->getMockOverExistingObject($srcObject, []);
     $mock->expects($this->any())->method('mockableProtectedMethod')->willReturn('test-value');
     $this->assertEquals('test-value', $mock->testMethod());
 }
开发者ID:speller,项目名称:phpunit-mock-objects,代码行数:11,代码来源:GeneratorTest.php

示例10: __construct

 function __construct($class, $params = array())
 {
     if (!class_exists($class)) {
         throw new \RuntimeException("Stubbed class {$class} doesn't exist");
     }
     $this->mockedClass = $class;
     $this->mock = PHPUnit_Framework_MockObject_Generator::getMock($class, array(), array(), '', false);
     $this->bindParameters($params);
 }
开发者ID:BatVane,项目名称:Codeception,代码行数:9,代码来源:EmptyStub.php

示例11: expects

 /**
  * Generates a mock object on the singleton Someclass util object.
  *
  * @param array $name
  * @return void
  */
 public static function expects($name, $replace)
 {
     // Mock the object
     $mock = \PHPUnit_Framework_MockObject_Generator::getMock('Someclass', array('hello'), array(), '', false);
     // Replace protected self reference with mock object
     $ref = new \ReflectionProperty('Someclass', 'self');
     $ref->setAccessible(true);
     $ref->setValue(null, $mock);
     // Set expectations and return values
     $mock->expects(new \PHPUnit_Framework_MockObject_Matcher_InvokedCount(1))->method('hello')->with(\PHPUnit_Framework_Assert::equalTo($name))->will(new \PHPUnit_Framework_MockObject_Stub_Return($replace));
 }
开发者ID:pkdevboxy,项目名称:zumba.github.com,代码行数:17,代码来源:someclass_mock.php

示例12: getFhirTemplate

 public static function getFhirTemplate()
 {
     class_exists('DataTemplate');
     $template = \PHPUnit_Framework_MockObject_Generator::getMock('DataTemplateComponent', array(), array(), '', false);
     $template->expects(new \PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount())->method('match')->will(new \PHPUnit_Framework_MockObject_Stub_ReturnCallback(function ($obj, &$warnings) {
         return get_object_vars($obj);
     }));
     $template->expects(new \PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount())->method('generate')->will(new \PHPUnit_Framework_MockObject_Stub_ReturnCallback(function ($values) {
         return (object) $values;
     }));
     return $template;
 }
开发者ID:openeyes,项目名称:openeyes,代码行数:12,代码来源:DataObjectTest.php

示例13: getMockFromWsdl

 /**
  * Returns a mock object based on the given WSDL file.
  *
  * @param  string  $wsdlFile
  * @param  string  $originalClassName
  * @param  string  $mockClassName
  * @param  array   $methods
  * @param  boolean $callOriginalConstructor
  * @return PHPUnit_Framework_MockObject_MockObject
  * @since  Method available since Release 3.4.0
  */
 protected function getMockFromWsdl($wsdlFile, $originalClassName = '', $mockClassName = '', array $methods = array(), $callOriginalConstructor = TRUE)
 {
     if ($originalClassName === '') {
         $originalClassName = str_replace('.wsdl', '', basename($wsdlFile));
     }
     eval(PHPUnit_Framework_MockObject_Generator::generateClassFromWsdl($wsdlFile, $originalClassName, $methods));
     return $this->getMock($originalClassName, $methods, array('', array()), $mockClassName, $callOriginalConstructor, FALSE, FALSE);
 }
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:19,代码来源:TestCase.php

示例14: testGetMockForAbstractClassAnstractClassDoesNotExist

 /**
  * @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
  * @expectedException PHPUnit_Framework_Exception
  */
 public function testGetMockForAbstractClassAnstractClassDoesNotExist()
 {
     $mock = PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass('Tux');
 }
开发者ID:jeanCarloMachado,项目名称:challenges,代码行数:8,代码来源:GeneratorTest.php

示例15: setUp

 public function setUp()
 {
     $this->unfilteredMessageBroker = $this->getMock('Deicer\\Pubsub\\UnfilteredMessageBrokerInterface');
     $this->topicFilteredMessageBroker = $this->getMock('Deicer\\Pubsub\\TopicFilteredMessageBrokerInterface');
     $this->messageBuilder = $this->getMock('Deicer\\Pubsub\\MessageBuilderInterface');
     $this->composite = $this->getMock('Deicer\\Model\\ModelCompositeInterface');
     $this->hydrator = $this->getMock('Deicer\\Model\\RecursiveModelCompositeHydratorInterface');
     $this->hydratorException = new TestableHydratorException('Unhandled hydrator exception');
     $this->message = $this->getMock('Deicer\\Pubsub\\MessageInterface');
     $this->subscriber = $this->getMock('Deicer\\Pubsub\\SubscriberInterface');
     $this->message->expects($this->any())->method('getPublisher')->will($this->returnValue($this->fixture));
     $this->messageBuilder->expects($this->any())->method('withTopic')->will($this->returnSelf());
     $this->messageBuilder->expects($this->any())->method('withContent')->will($this->returnSelf());
     $this->messageBuilder->expects($this->any())->method('withPublisher')->will($this->returnSelf());
     $this->messageBuilder->expects($this->any())->method('withAttributes')->will($this->returnSelf());
     $this->messageBuilder->expects($this->any())->method('build')->will($this->returnValue($this->message));
     $this->composite->expects($this->any())->method('count')->will($this->returnValue(0));
     // Hydrator returns composite with count equal to array element count
     $callback = function ($values) {
         $mockBuilder = new MockGenerator();
         $composite = $mockBuilder->getMock('Deicer\\Model\\ModelCompositeInterface');
         $composite->expects(TestCase::any())->method('count')->will(TestCase::returnValue(count($values)));
         return $composite;
     };
     $this->hydrator->expects($this->any())->method('exchangeArray')->with($this->isType('array'))->will($this->returnCallback($callback));
     $this->setUpFixture()->setUpFixtureWithExceptionThrowingFetchData()->setUpFixtureWithNonArrayReturningFetchData()->setUpFixtureWithEmptyArrayReturningFetchData()->setUpFixtureWithModelIncompatibleFetchData()->setUpFixtureWithDataProviderDependency()->setUpMockFixture();
 }
开发者ID:alex-butucea,项目名称:deicerframework,代码行数:27,代码来源:AbstractQueryTest.php


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