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


PHP PHPUnit_Framework_TestCase::assertInstanceOf方法代码示例

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


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

示例1: doCreate

 protected function doCreate(RecordInterface $record, Version $version)
 {
     $this->testCase->assertEquals(3, $record->getUserId());
     $this->testCase->assertEquals('test', $record->getTitle());
     $this->testCase->assertInstanceOf('DateTime', $record->getDate());
     return array('success' => true, 'message' => 'You have successful create a record');
 }
开发者ID:seytar,项目名称:psx,代码行数:7,代码来源:TestSchemaApiController.php

示例2: assertInstanceOf

 /**
  * Calls assertType() or assertInstanceOf() depending on the PHPUnit version.
  * Available from PHPUnit >= 3.5
  *
  * @param string $expected Expected value
  * @param mixed $actual Actual value
  * @param string $message Message to print if assertion is wrong
  */
 public static function assertInstanceOf($expected, $actual, $message = '')
 {
     if (self::_checkMethod('assertInstanceOf')) {
         parent::assertInstanceOf($expected, $actual, $message);
     } else {
         parent::assertType($expected, $actual, $message);
     }
 }
开发者ID:arcavias,项目名称:arcavias-core,代码行数:16,代码来源:Testcase.php

示例3: getPostFilter

 public function getPostFilter()
 {
     return array(function ($request, $response, $stack) {
         $this->testCase->assertInstanceOf('PSX\\Http\\Request', $request);
         $this->testCase->assertInstanceOf('PSX\\Http\\Response', $response);
         $stack->handle($request, $response);
     });
 }
开发者ID:seytar,项目名称:psx,代码行数:8,代码来源:TestController.php

示例4: assertInstanceOf

 /**
  * Asserts that a variable is of a given type.
  *
  * If $expected is an array, each string value will be used in a type
  * check. This is useful for checking if a class also implements certain
  * interfaces.
  *
  * @param string|array $expected
  * @param mixed $actual
  * @param string $message
  */
 public static function assertInstanceOf($expected, $actual, $message = '')
 {
     if (is_array($expected)) {
         foreach ($expected as $expectedSingle) {
             parent::assertInstanceOf($expectedSingle, $actual, $message);
         }
         return;
     }
     parent::assertInstanceOf($expected, $actual, $message);
 }
开发者ID:chromabits,项目名称:nucleus,代码行数:21,代码来源:TestCase.php

示例5: assertInstanceOf

 /**
  * Helper method to allow PHPUnit versions < 3.5.x
  *
  * @param string $expected The expected class or interface.
  * @param mixed  $actual   The actual variable/value.
  * @param string $message  Optional error/fail message.
  *
  * @return void
  * @since 0.10.2
  */
 public static function assertInstanceOf($expected, $actual, $message = '')
 {
     if (is_callable(get_parent_class(__CLASS__) . '::') . __FUNCTION__) {
         return parent::assertInstanceOf($expected, $actual, $message);
     }
     return parent::assertType($expected, $actual, $message);
 }
开发者ID:rouffj,项目名称:pdepend,代码行数:17,代码来源:AbstractTest.php

示例6: assertPropertyCollection

 /**
  * @param object $instance
  * @param string $propertyName
  * @param mixed $testItem
  */
 public static function assertPropertyCollection($instance, $propertyName, $testItem)
 {
     $propertyAccess = new CollectionAccessor($instance, $propertyName);
     // Check default value
     \PHPUnit_Framework_TestCase::assertInstanceOf('Doctrine\\Common\\Collections\\Collection', $propertyAccess->getItems(), $propertyName . ': Default value must be instance of Collection');
     // Check default size
     \PHPUnit_Framework_TestCase::assertCount(0, $propertyAccess->getItems(), $propertyName . ': Default collection size must be 0');
     // Add first item
     \PHPUnit_Framework_TestCase::assertSame($instance, $propertyAccess->addItem($testItem), sprintf('%s::%s() - must return %s', ClassUtils::getClass($instance), $propertyAccess->getAddItemMethod(), ClassUtils::getClass($instance)));
     // Check added item
     \PHPUnit_Framework_TestCase::assertCount(1, $propertyAccess->getItems(), $propertyName . ': After add item - collection size must be 1');
     \PHPUnit_Framework_TestCase::assertInstanceOf('Doctrine\\Common\\Collections\\Collection', $propertyAccess->getItems(), $propertyName . ': After addition of a first item - property value must be instance of Collection');
     \PHPUnit_Framework_TestCase::assertEquals([$testItem], $propertyAccess->getItems()->toArray(), $propertyName . ': After addition of a first item - collections must be equals');
     // Add already added item
     $propertyAccess->addItem($testItem);
     \PHPUnit_Framework_TestCase::assertCount(1, $propertyAccess->getItems(), $propertyName . ': After addition already added item - collection size must be same and equal 1');
     // Remove item
     \PHPUnit_Framework_TestCase::assertSame($instance, $propertyAccess->removeItem($testItem), sprintf('%s:%s() - must return %s', ClassUtils::getClass($instance), $propertyAccess->getRemoveItemMethod(), ClassUtils::getClass($instance)));
     \PHPUnit_Framework_TestCase::assertCount(0, $propertyAccess->getItems(), $propertyName . ': After removal of a single item - collection size must be 0');
     // Remove already removed item
     $propertyAccess->removeItem($testItem);
     \PHPUnit_Framework_TestCase::assertCount(0, $propertyAccess->getItems(), $propertyName . ': After removal already removed item - collection size must be same and equal 0');
     \PHPUnit_Framework_TestCase::assertNotContains($testItem, $propertyAccess->getItems()->toArray(), $propertyName . ': After removal of a single item - collection must not contains test item');
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:29,代码来源:EntityTestCaseTrait.php

示例7: testGet

 public function testGet()
 {
     $get = $this->entityGet();
     if (is_object($get)) {
         TestCase::assertInstanceOf("Countable", $get, $this->msg(self::$MSG_GET_METHOD_MUST_RETURN_COUNTABLE_OBJECT));
         TestCase::assertInstanceOf("Traversable", $get, $this->msg(self::$MSG_GET_METHOD_MUST_RETURN_TRAVERSABLE_OBJECT));
     } elseif (!is_null($get)) {
         TestCase::assertInternalType("array", $get, $this->msg(self::$MSG_GET_METHOD_MUST_RETURN_AN_ARRAY));
     } else {
         throw new AssertionFailedError($this->msg(self::$MSG_GET_METHOD_MUST_NOT_RETURN_NULL));
     }
 }
开发者ID:jngermon,项目名称:phpunit-entity-tester,代码行数:12,代码来源:AccessorCollectionTester.php

示例8: assertIsA

 /**
  * @deprecated since 2.3
  * @static
  * @param mixed $actual
  * @param mixed $expected
  * @param string $message
  */
 public static function assertIsA($actual, $expected, $message = '')
 {
     parent::assertInstanceOf($expected, $actual, $message);
 }
开发者ID:nickread,项目名称:moodle,代码行数:11,代码来源:lib.php

示例9: onExecute

 public function onExecute(Parameters $parameters, OutputInterface $output)
 {
     // test properties
     $this->testCase->assertInstanceOf('PSX\\Loader\\Context', $this->context);
     $this->testCase->assertInstanceOf('PSX\\Config', $this->config);
 }
开发者ID:seytar,项目名称:psx,代码行数:6,代码来源:TestCommand.php

示例10: emptyHandlers

 /**
  * @test
  */
 public function emptyHandlers()
 {
     $handlers = $this->handlerContainer->getHandlers();
     parent::assertInstanceOf(\Traversable::class, $handlers);
     parent::assertEmpty($handlers);
 }
开发者ID:oqq,项目名称:minc-log,代码行数:9,代码来源:HandlerContainerTest.php

示例11: assertInstanceOfCompiledExpression

 /**
  * @param CompiledExpression|null $actual
  * @param string $message
  */
 protected function assertInstanceOfCompiledExpression($actual, $message = '')
 {
     parent::assertInstanceOf(CompiledExpression::class, $actual, $message);
 }
开发者ID:ovr,项目名称:phpsa,代码行数:8,代码来源:TestCase.php

示例12: assertRecord

 /**
  * Checks whether the data we received as post is converted to the right
  * types
  *
  * @param \PHPUnit_Framework_TestCase $testCase
  * @param \PSX\Data\RecordInterface $record
  */
 public static function assertRecord(\PHPUnit_Framework_TestCase $testCase, RecordInterface $record)
 {
     $testCase->assertInternalType('array', $record->getArray());
     $testCase->assertEquals(1, count($record->getArray()));
     $testCase->assertEquals(['bar'], $record->getArray());
     $testCase->assertInternalType('array', $record->getArrayComplex());
     $testCase->assertEquals(2, count($record->getArrayComplex()));
     $testCase->assertInstanceOf('PSX\\Data\\RecordInterface', $record->getArrayComplex()[0]);
     $testCase->assertEquals(['foo' => 'bar'], $record->getArrayComplex()[0]->getRecordInfo()->getFields());
     $testCase->assertInstanceOf('PSX\\Data\\RecordInterface', $record->getArrayComplex()[1]);
     $testCase->assertEquals(['foo' => 'foo'], $record->getArrayComplex()[1]->getRecordInfo()->getFields());
     $testCase->assertInternalType('array', $record->getArrayChoice());
     $testCase->assertEquals(3, count($record->getArrayChoice()));
     $testCase->assertInstanceOf('PSX\\Data\\RecordInterface', $record->getArrayChoice()[0]);
     $testCase->assertEquals(['foo' => 'baz'], $record->getArrayChoice()[0]->getRecordInfo()->getFields());
     $testCase->assertInstanceOf('PSX\\Data\\RecordInterface', $record->getArrayChoice()[1]);
     $testCase->assertEquals(['bar' => 'bar'], $record->getArrayChoice()[1]->getRecordInfo()->getFields());
     $testCase->assertInstanceOf('PSX\\Data\\RecordInterface', $record->getArrayChoice()[2]);
     $testCase->assertEquals(['foo' => 'foo'], $record->getArrayChoice()[2]->getRecordInfo()->getFields());
     $testCase->assertInternalType('boolean', $record->getBoolean());
     $testCase->assertEquals(true, $record->getBoolean());
     $testCase->assertInstanceOf('PSX\\Data\\RecordInterface', $record->getChoice());
     $testCase->assertEquals(['foo' => 'bar'], $record->getComplex()->getRecordInfo()->getFields());
     $testCase->assertInstanceOf('PSX\\Data\\RecordInterface', $record->getComplex());
     $testCase->assertEquals(['foo' => 'bar'], $record->getComplex()->getRecordInfo()->getFields());
     $testCase->assertInstanceOf('PSX\\DateTime\\Date', $record->getDate());
     $testCase->assertEquals('2015-05-01', $record->getDate()->format('Y-m-d'));
     $testCase->assertInstanceOf('PSX\\DateTime', $record->getDateTime());
     $testCase->assertEquals('2015-05-01T13:37:14Z', $record->getDateTime()->format('Y-m-d\\TH:i:s\\Z'));
     $testCase->assertInstanceOf('PSX\\DateTime\\Duration', $record->getDuration());
     $testCase->assertEquals('000100000000', $record->getDuration()->format('%Y%M%D%H%I%S'));
     $testCase->assertInternalType('float', $record->getFloat());
     $testCase->assertEquals(13.37, $record->getFloat());
     $testCase->assertInternalType('integer', $record->getInteger());
     $testCase->assertEquals(7, $record->getInteger());
     $testCase->assertInternalType('string', $record->getString());
     $testCase->assertEquals('bar', $record->getString());
     $testCase->assertInstanceOf('PSX\\DateTime\\Time', $record->getTime());
     $testCase->assertEquals('13:37:14', $record->getTime()->format('H:i:s'));
 }
开发者ID:seytar,项目名称:psx,代码行数:47,代码来源:PropertyTestCase.php

示例13: prepare

 protected function prepare()
 {
     $this->container = \Mockery::mock(Container::class)->makePartial();
     $schemaMapper = \Mockery::mock(SchemaMapper::class)->makePartial();
     $schemaMapper->shouldReceive('buildCredentialsFromInlineFormat')->once()->passthru();
     $this->container->shouldReceive('resolve')->once()->with('Domain\\Mapper\\Schema')->andReturn($schemaMapper);
     $credentialsMatcher = \Mockery::on(function ($args) {
         /** @var CredentialsInterface $credentials */
         $credentials = $args[0];
         \PHPUnit_Framework_TestCase::assertInstanceOf(CredentialsInterface::class, $credentials);
         $actual = $credentials->toArray();
         $expected = ["username" => "user1", "password" => "pass2", "host" => "sample.host", "database" => "sample_database"];
         if ($expected != $actual) {
             \PHPUnit_Framework_TestCase::fail('Check credentials format or sample.');
         }
         return true;
     });
     $pdo = \Mockery::mock(\PDO::class);
     $this->container->shouldReceive('resolve')->once()->with('Persistence\\Storage\\PDO', $credentialsMatcher)->andReturn($pdo);
     $storageMatcher = \Mockery::on(function ($args) use($pdo) {
         /** @var StorageInterface $storage */
         $storage = $args[0];
         if ($pdo != $storage) {
             \PHPUnit_Framework_TestCase::fail('Check pipes.');
         }
         return true;
     });
     $gateway = \Mockery::mock(MySQLGateway::class);
     $this->container->shouldReceive('resolve')->once()->with('Persistence\\Gateway\\Schema\\MySQL', $storageMatcher)->andReturn($gateway);
     $gatewayAndMapperMatcher = \Mockery::on(function ($args) use($gateway, $schemaMapper) {
         if ($args[0] != $gateway) {
             \PHPUnit_Framework_TestCase::fail('Gateway mismatch.');
         }
         if ($args[1] != $schemaMapper) {
             \PHPUnit_Framework_TestCase::fail('Mapper mismatch.');
         }
         return true;
     });
     $this->schemaService = \Mockery::mock(SchemaService::class);
     $this->container->shouldReceive('resolve')->once()->with('Infrastructure\\Services\\Schema', $gatewayAndMapperMatcher)->andReturn($this->schemaService);
     $classCommand = '\\DatabaseInspect\\Console\\Command\\DetailsCommand[execute]';
     $this->command = \Mockery::mock($classCommand, [$this->container])->makePartial();
     $this->input = \Mockery::mock(ArgvInput::class);
     $this->input->shouldReceive('getArgument')->once()->andReturn('user1:pass2@sample.host/sample_database');
     $this->output = \Mockery::mock(ConsoleOutput::class);
 }
开发者ID:bogdananton,项目名称:mysql-structure-inspect,代码行数:46,代码来源:ExecuteTest.php

示例14: doCreate

 protected function doCreate(RecordInterface $record, Version $version)
 {
     $this->testCase->assertEquals(3, $record->getUserId());
     $this->testCase->assertEquals('test', $record->getTitle());
     $this->testCase->assertInstanceOf('DateTime', $record->getDate());
 }
开发者ID:seytar,项目名称:psx,代码行数:6,代码来源:NoResponseController.php

示例15: test_debug_function_is_called

 public function test_debug_function_is_called()
 {
     $this->http->method('request')->will($this->returnCallback(function () {
         return new \Communique\RESTClientResponse(200, 'response+payload', array('X-PoweredBy' => 'Dreams'));
     }));
     $rest = new \Communique\Communique('http://domain.com/', array(), $this->http);
     $rest->get('users', array('request' => 'payload'), array('Foo' => 'Bar'), function ($request, $response) {
         PHPUnit_Framework_TestCase::assertInstanceOf('\\Communique\\RESTClientRequest', $request);
         PHPUnit_Framework_TestCase::assertEquals($request->url, 'http://domain.com/users');
         PHPUnit_Framework_TestCase::assertEquals($request->payload, array('request' => 'payload'));
         PHPUnit_Framework_TestCase::assertEquals($request->headers, array('Foo' => 'Bar'));
         PHPUnit_Framework_TestCase::assertInstanceOf('\\Communique\\RESTClientResponse', $response);
         PHPUnit_Framework_TestCase::assertEquals($response->status, 200);
         PHPUnit_Framework_TestCase::assertEquals($response->payload, 'response+payload');
         PHPUnit_Framework_TestCase::assertEquals($response->headers, array('X-PoweredBy' => 'Dreams'));
     });
 }
开发者ID:Remo,项目名称:communique,代码行数:17,代码来源:CommuniqueTest.php


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