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


PHP PHPUnit_Framework_TestCase类代码示例

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


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

示例1: getTestFileName

 public static function getTestFileName(\PHPUnit_Framework_TestCase $testCase)
 {
     if ($testCase instanceof TestCase\Interfaces\Descriptive) {
         return $testCase->getFileName();
     }
     return (new \ReflectionClass($testCase))->getFileName();
 }
开发者ID:hitechdk,项目名称:Codeception,代码行数:7,代码来源:TestCase.php

示例2: getReaderMock

 /**
  * @param \PHPUnit_Framework_TestCase $testCase
  * @param array $results
  * @return XmlReader
  */
 public function getReaderMock(\PHPUnit_Framework_TestCase $testCase, array $results)
 {
     $result = new PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls(array_merge($results, []));
     $reader = $testCase->getMockBuilder('\\DataSource\\XmlReader')->disableOriginalConstructor()->getMock();
     $reader->expects(static::any())->method('getRows')->will($result);
     return $reader;
 }
开发者ID:apolev,项目名称:fias,代码行数:12,代码来源:TestAbstract.php

示例3: check

 public static function check(\PHPUnit_Framework_TestCase $test, SSODescriptor $descriptor, array $expectedNameIdFormats)
 {
     $test->assertCount(count($expectedNameIdFormats), $descriptor->getAllNameIDFormats());
     foreach ($expectedNameIdFormats as $nameIdFormat) {
         $test->assertTrue($descriptor->hasNameIDFormat($nameIdFormat));
     }
 }
开发者ID:aarnaud,项目名称:lightSAML,代码行数:7,代码来源:NameIdFormatChecker.php

示例4: check

 public static function check(\PHPUnit_Framework_TestCase $test, $name, $display, $url, Organization $organization = null)
 {
     $test->assertNotNull($organization);
     $test->assertEquals($name, $organization->getOrganizationName());
     $test->assertEquals($display, $organization->getOrganizationDisplayName());
     $test->assertEquals($url, $organization->getOrganizationURL());
 }
开发者ID:aarnaud,项目名称:lightSAML,代码行数:7,代码来源:OrganizationChecker.php

示例5: create

 /**
  * Create a new mock of the curlbuilder and return
  * the given filename as content
  *
  * @access public
  * @param  PHPUnit_Framework_TestCase   $instance
  * @return mock
  */
 public static function create($instance)
 {
     $reflection = new \ReflectionMethod($instance, $instance->getName());
     $doc_block = $reflection->getDocComment();
     $responsefile = self::parseDocBlock($doc_block, '@responsefile');
     $responsecode = self::parseDocBlock($doc_block, '@responsecode');
     $defaultheaders = array("X-Ratelimit-Limit" => "1000", "X-Ratelimit-Remaining" => "998", "X-Varnish" => "4059929980");
     $skipmock = self::parseDocBlock($doc_block, '@skipmock');
     if (empty($responsecode)) {
         $responsecode = [201];
     }
     if (empty($responsefile)) {
         $responsefile = [$instance->getName()];
     }
     // Setup Curlbuilder mock
     $curlbuilder = $instance->getMockBuilder("\\DirkGroenen\\Pinterest\\Utils\\CurlBuilder")->getMock();
     $curlbuilder->expects($instance->any())->method('create')->will($instance->returnSelf());
     // Build response file path
     $responseFilePath = __DIR__ . '/../responses/' . (new \ReflectionClass($instance))->getShortName() . '/' . $responsefile[0] . ".json";
     if (file_exists($responseFilePath)) {
         $curlbuilder->expects($instance->once())->method('execute')->will($instance->returnValue(file_get_contents($responseFilePath)));
     }
     $curlbuilder->expects($instance->any())->method('getInfo')->will($instance->returnValue($responsecode[0]));
     return $curlbuilder;
 }
开发者ID:veksa,项目名称:Pinterest-API-PHP,代码行数:33,代码来源:CurlBuilderMock.php

示例6: setUpContext

 /**
  * @param \PHPUnit_Framework_TestCase $testCase
  */
 private function setUpContext(\PHPUnit_Framework_TestCase $testCase)
 {
     $annotations = $testCase->getAnnotations();
     if (isset($annotations['method'][$this->annotationName])) {
         $this->callMethods($testCase, $annotations['method'][$this->annotationName]);
     }
 }
开发者ID:nikoms,项目名称:phpunit-dynamic-fixture,代码行数:10,代码来源:DynamicFixtureListener.php

示例7: registerComponents

 /**
  * Register fixture components
  *
  * @param \PHPUnit_Framework_TestCase $test
  */
 private function registerComponents(\PHPUnit_Framework_TestCase $test)
 {
     $annotations = $test->getAnnotations();
     $componentAnnotations = [];
     if (isset($annotations['class'][self::ANNOTATION_NAME])) {
         $componentAnnotations = array_merge($componentAnnotations, $annotations['class'][self::ANNOTATION_NAME]);
     }
     if (isset($annotations['method'][self::ANNOTATION_NAME])) {
         $componentAnnotations = array_merge($componentAnnotations, $annotations['method'][self::ANNOTATION_NAME]);
     }
     if (empty($componentAnnotations)) {
         return;
     }
     $componentAnnotations = array_unique($componentAnnotations);
     $reflection = new \ReflectionClass(self::REGISTRAR_CLASS);
     $paths = $reflection->getProperty(self::PATHS_FIELD);
     $paths->setAccessible(true);
     $this->origComponents = $paths->getValue();
     $paths->setAccessible(false);
     foreach ($componentAnnotations as $fixturePath) {
         $fixturesDir = $this->fixtureBaseDir . '/' . $fixturePath;
         if (!file_exists($fixturesDir)) {
             throw new \InvalidArgumentException(self::ANNOTATION_NAME . " fixture '{$fixturePath}' does not exist");
         }
         $iterator = new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($fixturesDir, \FilesystemIterator::SKIP_DOTS)), '/^.+\\/registration\\.php$/');
         /**
          * @var \SplFileInfo $registrationFile
          */
         foreach ($iterator as $registrationFile) {
             require $registrationFile->getRealPath();
         }
     }
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:38,代码来源:ComponentRegistrarFixture.php

示例8: testMerge

 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testMerge()
 {
     $fieldData = $this->createFieldData();
     $fieldMetadataData = $this->createFieldMetadata();
     $entityData = $this->createEntityData();
     $masterEntity = new EntityStub(1);
     $sourceEntity = new EntityStub(2);
     $collectionItem1 = new CollectionItemStub(1);
     $collectionItem2 = new CollectionItemStub(2);
     $masterEntity->addCollectionItem($collectionItem1);
     $sourceEntity->addCollectionItem($collectionItem2);
     $entities = [$masterEntity, $sourceEntity];
     $relatedEntities = [$collectionItem1, $collectionItem2];
     $fieldData->expects($this->once())->method('getEntityData')->will($this->returnValue($entityData));
     $fieldData->expects($this->once())->method('getMetadata')->will($this->returnValue($fieldMetadataData));
     $entityData->expects($this->once())->method('getEntities')->will($this->returnValue($entities));
     $entityData->expects($this->once())->method('getMasterEntity')->will($this->returnValue($masterEntity));
     $this->doctrineHelper->expects($this->any())->method('getEntityIdentifierValue')->will($this->returnCallback(function ($value) {
         return $value->getId();
     }));
     $fieldDoctrineMetadata = $this->createDoctrineMetadata();
     $fieldDoctrineMetadata->expects($this->any())->method('getFieldName')->will($this->returnValue('field_name'));
     $fieldMetadataData->expects($this->any())->method('getDoctrineMetadata')->will($this->returnValue($fieldDoctrineMetadata));
     $fieldMetadataData->expects($this->any())->method('getFieldName')->will($this->returnValue('collection'));
     $fieldMetadataData->expects($this->any())->method('has')->will($this->returnValue(true));
     $fieldMetadataData->expects($this->any())->method('get')->will($this->returnValue('setEntityStub'));
     $repository = $this->getMockBuilder('Doctrine\\Common\\Persistence\\ObjectRepository')->disableOriginalConstructor()->getMock();
     $this->doctrineHelper->expects($this->any())->method('getEntityRepository')->will($this->returnValue($repository));
     $repository->expects($this->any())->method('findBy')->will($this->returnCallback(function ($values) use($relatedEntities) {
         return [$relatedEntities[$values['field_name']->getId() - 1]];
     }));
     $this->strategy->merge($fieldData);
     $this->assertEquals($masterEntity, $collectionItem1->getEntityStub());
     $this->assertEquals($masterEntity, $collectionItem2->getEntityStub());
 }
开发者ID:Maksold,项目名称:platform,代码行数:38,代码来源:UniteStrategyTest.php

示例9: testMainFlow

 /**
  * @dataProvider callbackDataProvider
  *
  * @param string $expectedMessage
  * @param string $expectedMethod
  * @param string $exceptionClass
  * @throws
  */
 public function testMainFlow($expectedMessage, $expectedMethod, $exceptionClass)
 {
     $this->_testCase->expects($this->any())->method($expectedMethod)->with($this->stringStartsWith($expectedMessage));
     $this->_invoker->__invoke(function () use($exceptionClass) {
         throw new $exceptionClass('Some meaningful message.');
     }, [[0]]);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:AggregateInvokerTest.php

示例10: getArgumentMock

 /**
  * @param \ReflectionParameter $parameter
  * @return mixed
  */
 private function getArgumentMock(\ReflectionParameter $parameter)
 {
     if ($parameter->getClass() !== null) {
         return $this->testCase->getMockBuilder($parameter->getClass()->getName())->disableOriginalConstructor()->getMock();
     }
     throw new \Mocktainer\UnmockableMethodArgumentException($parameter->getDeclaringClass()->getName(), $parameter->getDeclaringFunction()->getName(), $parameter->getName());
 }
开发者ID:paranoiq,项目名称:mocktainer,代码行数:11,代码来源:Mocktainer.php

示例11: testFactory

 /**
  * Test a factory.
  *
  * @param  string $className
  * @return void
  */
 public function testFactory($classname, array $requiredOptions, array $options)
 {
     // Test that the factory does not allow a scalar option.
     try {
         $classname::factory(0);
         $this->testCase->fail('An expected exception was not thrown');
     } catch (\Zend\Mvc\Router\Exception\InvalidArgumentException $e) {
         $this->testCase->assertContains('factory expects an array or Traversable set of options', $e->getMessage());
     }
     // Test required options.
     foreach ($requiredOptions as $option => $exceptionMessage) {
         $testOptions = $options;
         unset($testOptions[$option]);
         try {
             $classname::factory($testOptions);
             $this->testCase->fail('An expected exception was not thrown');
         } catch (\Zend\Mvc\Router\Exception\InvalidArgumentException $e) {
             $this->testCase->assertContains($exceptionMessage, $e->getMessage());
         }
     }
     // Create the route, will throw an exception if something goes wrong.
     $classname::factory($options);
     // Try the same with an iterator.
     $classname::factory(new ArrayIterator($options));
 }
开发者ID:ninahuanca,项目名称:zf2,代码行数:31,代码来源:FactoryTester.php

示例12: getReadMock

 /**
  * @param TblCronTask[] $cronTasks
  * @return \Trovit\CronManagerBundle\Repository\TblCronTaskRepository|\PHPUnit_Framework_MockObject_MockObject
  */
 public function getReadMock(array $cronTasks)
 {
     $mock = $this->getBasicMock();
     $mock->expects($this->_testCase->once())->method('findAll')->willReturn($cronTasks);
     $mock->expects($this->_testCase->once())->method('getActiveCronTasks')->willReturn($cronTasks);
     return $mock;
 }
开发者ID:viscat,项目名称:PCCronManagerBundle,代码行数:11,代码来源:TblCronTaskRepositoryMocks.php

示例13: buildStub

 protected function buildStub($will)
 {
     if (!is_object($will) || !$will instanceof PHPUnit_Framework_MockObject_Stub) {
         $will = $this->testCase->returnValue($this->buildIfValueIsABuilder($will));
     }
     return $will;
 }
开发者ID:schnipseljagd,项目名称:testdatabuilder,代码行数:7,代码来源:StubBuilder.php

示例14: getArgumentMock

 /**
  * @param string $className
  * @param string $argumentName
  * @param \ReflectionParameter $parameter
  * @return mixed
  */
 private function getArgumentMock(string $className, string $argumentName, \ReflectionParameter $parameter)
 {
     if ($parameter->getClass() !== null) {
         return $this->testCase->getMockBuilder($parameter->getClass()->name)->disableOriginalConstructor()->getMock();
     }
     throw new \Mocktainer\UnmockableConstructorArgumentException($className, $argumentName);
 }
开发者ID:ondrejmirtes,项目名称:mocktainer,代码行数:13,代码来源:Mocktainer.php

示例15: getMock

 public function getMock()
 {
     $mock = $this->testCase->getMock('stdClass', $this->functions, array(), 'PHPUnit_Extension_FunctionMocker_' . uniqid());
     foreach ($this->functions as $function) {
         $fqFunction = $this->namespace . '\\' . $function;
         if (in_array($fqFunction, static::$mockedFunctions, true)) {
             continue;
         }
         if (!extension_loaded('runkit') || !ini_get('runkit.internal_override')) {
             PHPUnit_Extension_FunctionMocker_CodeGenerator::defineFunction($function, $this->namespace);
         } elseif (!function_exists('__phpunit_function_mocker_' . $function)) {
             runkit_function_rename($function, '__phpunit_function_mocker_' . $function);
             error_log($function);
             runkit_method_redefine($function, function () use($function) {
                 if (!isset($GLOBALS['__PHPUNIT_EXTENSION_FUNCTIONMOCKER'][$this->namespace])) {
                     return call_user_func_array('__phpunit_function_mocker_' . $function, func_get_args());
                 }
                 return call_user_func_array(array($GLOBALS['__PHPUNIT_EXTENSION_FUNCTIONMOCKER'][$this->namespace], $function), func_get_args());
             });
             var_dump(strlen("foo"));
         }
         static::$mockedFunctions[] = $fqFunction;
     }
     if (!isset($GLOBALS['__PHPUNIT_EXTENSION_FUNCTIONMOCKER'])) {
         $GLOBALS['__PHPUNIT_EXTENSION_FUNCTIONMOCKER'] = array();
     }
     $GLOBALS['__PHPUNIT_EXTENSION_FUNCTIONMOCKER'][$this->namespace] = $mock;
     return $mock;
 }
开发者ID:Dossar,项目名称:boltbse,代码行数:29,代码来源:FunctionMocker.php


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