• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP assert\assert函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: classAnnotatedWithSingletonWillOnlyBeCreatedOnce

 /**
  * @test
  */
 public function classAnnotatedWithSingletonWillOnlyBeCreatedOnce()
 {
     $binder = new Binder();
     $binder->bind(Number::class)->to(RandomSingleton::class);
     $slot = $binder->getInjector()->getInstance(SlotMachine::class);
     assert($slot->number1, isInstanceOf(RandomSingleton::class)->and(isSameAs($slot->number2)));
 }
开发者ID:stubbles,项目名称:stubbles-ioc,代码行数:10,代码来源:InjectorSingletonScopeTest.php


示例2: otherScopeIsUsedToCreateInstance

 /**
  * @test
  */
 public function otherScopeIsUsedToCreateInstance()
 {
     $binder = new Binder();
     $instance = new \stdClass();
     $binder->bind(\stdClass::class)->to(\stdClass::class)->in(NewInstance::of(BindingScope::class)->mapCalls(['getInstance' => $instance]));
     assert($binder->getInjector()->getInstance(\stdClass::class), isSameAs($instance));
 }
开发者ID:stubbles,项目名称:stubbles-ioc,代码行数:10,代码来源:InjectorUserDefinedScopeTest.php


示例3: createsInstanceIfNotPresent

 /**
  * @test
  */
 public function createsInstanceIfNotPresent()
 {
     $instance = new \stdClass();
     $this->prepareSession(['hasValue' => false]);
     $this->provider->mapCalls(['get' => $instance]);
     assert($this->sessionScope->getInstance(reflect(\stdClass::class), $this->provider), isSameAs($instance));
 }
开发者ID:stubbles,项目名称:stubbles-ioc,代码行数:10,代码来源:SessionBindingScopeTest.php


示例4: outputStreamGetsPrefix

 /**
  * @test
  */
 public function outputStreamGetsPrefix()
 {
     $outputStream = NewInstance::of(OutputStream::class);
     $this->streamFactory->mapCalls(['createOutputStream' => $outputStream]);
     assert($this->prefixedStreamFactory->createOutputStream('foo', ['bar' => 'baz']), isSameAs($outputStream));
     verify($this->streamFactory, 'createOutputStream')->received('prefix/foo', ['bar' => 'baz']);
 }
开发者ID:stubbles,项目名称:stubbles-streams,代码行数:10,代码来源:PrefixedStreamFactoryTest.php


示例5: injectWithProviderClass

 /**
  * @test
  */
 public function injectWithProviderClass()
 {
     $binder = new Binder();
     $binder->bind(Answer::class)->toProviderClass(new \ReflectionClass(MyProviderClass::class));
     $question = $binder->getInjector()->getInstance(AnotherQuestion::class);
     assert($question->getAnswer(), isInstanceOf(Answer::class));
 }
开发者ID:stubbles,项目名称:stubbles-ioc,代码行数:10,代码来源:InjectorProviderTest.php


示例6: writesToStandardOutputBuffer

 /**
  * @test
  */
 public function writesToStandardOutputBuffer()
 {
     $out = new StandardOutputStream();
     ob_start();
     $out->write('foo');
     assert(ob_get_contents(), equals('foo'));
     ob_end_clean();
 }
开发者ID:stubbles,项目名称:stubbles-streams,代码行数:11,代码来源:StandardOutputStreamTest.php


示例7: canIterateOverNonSeekableInputStream

 /**
  * @test
  */
 public function canIterateOverNonSeekableInputStream()
 {
     $inputStream = NewInstance::of(InputStream::class)->mapCalls(['readLine' => onConsecutiveCalls('foo', 'bar', 'baz', ''), 'eof' => onConsecutiveCalls(false, false, false, true)]);
     $content = [];
     foreach (linesOf($inputStream) as $lineNumber => $line) {
         $content[$lineNumber] = $line;
     }
     assert($content, equals([1 => 'foo', 2 => 'bar', 3 => 'baz']));
 }
开发者ID:stubbles,项目名称:stubbles-streams,代码行数:12,代码来源:InputStreamIteratorTest.php


示例8: injectWithClosure

 /**
  * @test
  */
 public function injectWithClosure()
 {
     $binder = new Binder();
     $answer = new Answer();
     $binder->bind(Answer::class)->toClosure(function () use($answer) {
         return $answer;
     });
     $question = $binder->getInjector()->getInstance(AnotherQuestion::class);
     assert($question, isInstanceOf(AnotherQuestion::class));
     assert($question->getAnswer(), isSameAs($answer));
 }
开发者ID:stubbles,项目名称:stubbles-ioc,代码行数:14,代码来源:InjectorClosureTest.php


示例9: keyConsumerIsNotCalledWhenNoKeyInForeachRequested

 /**
  * @test
  */
 public function keyConsumerIsNotCalledWhenNoKeyInForeachRequested()
 {
     $i = 0;
     $peek = new Peek(new \ArrayIterator(['foo' => 303, 'bar' => 404, 'baz' => 505]), function () {
     }, function () {
         fail('Key consumer is not expected to be called');
     });
     foreach ($peek as $value) {
         $i++;
     }
     assert($i, equals(3));
 }
开发者ID:stubbles,项目名称:stubbles-sequence,代码行数:15,代码来源:PeekTest.php


示例10: infiniteGeneratorDoesStopOnlyWhenBreakOutOfLoop

 /**
  * @test
  */
 public function infiniteGeneratorDoesStopOnlyWhenBreakOutOfLoop()
 {
     $i = 0;
     foreach (Generator::infinite(0, function ($value) {
         return $value + 2;
     }) as $key => $value) {
         if (1000 > $key) {
             $i++;
         } else {
             break;
         }
     }
     assert($i, equals(1000));
 }
开发者ID:stubbles,项目名称:stubbles-sequence,代码行数:17,代码来源:GeneratorTest.php


示例11: createsLogDirectoryWithChangedModeIfNotExists

 /**
  * @test
  * @dataProvider  throwables
  */
 public function createsLogDirectoryWithChangedModeIfNotExists($throwable)
 {
     $this->exceptionLogger->setFilemode(0777)->log($throwable);
     assert($this->root->getChild(self::$logPath)->getPermissions(), equals(0777));
 }
开发者ID:stubbles,项目名称:stubbles-ioc,代码行数:9,代码来源:ExceptionLoggerTest.php


示例12: explicitBindingOverwritesProvidedByAnnotation

 /**
  * @test
  */
 public function explicitBindingOverwritesProvidedByAnnotation()
 {
     $binder = new Binder();
     $binder->bind(Person2::class)->to(Mikey::class);
     assert($binder->getInjector()->getInstance(Person2::class), isInstanceOf(Mikey::class));
 }
开发者ID:stubbles,项目名称:stubbles-ioc,代码行数:9,代码来源:InjectorProvidedByTest.php


示例13: deleteWritesCorrectRequestWithVersion

 /**
  * @since   2.0.0
  * @test
  */
 public function deleteWritesCorrectRequestWithVersion()
 {
     $this->createHttpRequest()->delete(5, HttpVersion::HTTP_1_0);
     assert($this->memory, equals(Http::lines('DELETE /foo/resource HTTP/1.0', 'Host: example.com', 'X-Binford: 6100', '')));
 }
开发者ID:stubbles,项目名称:stubbles-peer,代码行数:9,代码来源:HttpRequestTest.php


示例14: toMapPassesKeyAndValueWhenNoSelectorProvided

 /**
  * @test
  */
 public function toMapPassesKeyAndValueWhenNoSelectorProvided()
 {
     assert(Sequence::of($this->people)->collect()->inMap(), equals($this->people));
 }
开发者ID:stubbles,项目名称:stubbles-sequence,代码行数:7,代码来源:CollectorTest.php


示例15: propertyBindingUsedWhenParamHasTypeHintButIsAnnotated

 /**
  * @test
  * @since  4.1.3
  */
 public function propertyBindingUsedWhenParamHasTypeHintButIsAnnotated()
 {
     try {
         $binder = new Binder();
         $properties = new Properties(['config' => ['example.password' => 'somePassword']]);
         $binder->bindProperties($properties, 'PROD');
         $example = $binder->getInjector()->getInstance(Example::class);
         assert($example->password, isInstanceOf(Secret::class));
     } finally {
         // ensure all references are removed to clean up environment
         unset($properties);
         $example->password = null;
         unset($example);
         unset($binder);
         gc_collect_cycles();
     }
 }
开发者ID:stubbles,项目名称:stubbles-ioc,代码行数:21,代码来源:PropertyBindingTest.php


示例16: namedConstructorInjectionWithMultipleParamAndNamedParamGroup

 /**
  * @test
  */
 public function namedConstructorInjectionWithMultipleParamAndNamedParamGroup()
 {
     $binder = new Binder();
     $binder->bind(Employee::class)->named('schst')->to(Boss::class);
     $binder->bind(Employee::class)->to(TeamMember::class);
     $injector = $binder->getInjector();
     $group = $injector->getInstance(DevelopersMultipleConstructorParamsGroupedName::class);
     assert($group, equals(new DevelopersMultipleConstructorParamsGroupedName(new Boss(), new Boss())));
 }
开发者ID:stubbles,项目名称:stubbles-ioc,代码行数:12,代码来源:InjectorNamedTest.php


示例17: exportsAnyThingElseWithDefault

 /**
  * @test
  */
 public function exportsAnyThingElseWithDefault()
 {
     assert(Provides::values([1])->describeValue(exporter(), 'foo'), equals('\'foo\''));
 }
开发者ID:stubbles,项目名称:stubbles-sequence,代码行数:7,代码来源:ProvidesTest.php


示例18: parseRecognizesHttpsUris

 /**
  * @test
  */
 public function parseRecognizesHttpsUris()
 {
     assert(Parse::toType('https://example.net/'), equals(HttpUri::fromString('https://example.net/')));
 }
开发者ID:stubbles,项目名称:stubbles-peer,代码行数:7,代码来源:ParseTest.php


示例19: usesImplementationSpecifiedForMode

 /**
  * @test
  * @since  6.0.0
  */
 public function usesImplementationSpecifiedForMode()
 {
     $binder = new Binder();
     assert($binder->setEnvironment('DEV')->getInjector()->getInstance(Person3::class), isInstanceOf(Mikey::class));
 }
开发者ID:stubbles,项目名称:stubbles-ioc,代码行数:9,代码来源:InjectorImplementedByTest.php


示例20: getPurgePatternFromLastRequest

 /**
  * Retrieve the purge pattern from the last purge request.
  *
  * @return string
  *   The purge pattern, which is a regular expression.
  */
 private function getPurgePatternFromLastRequest()
 {
     $requests = $this->getRequests();
     assert($requests, isOfSize(1));
     $purge_request = $requests->last();
     $purge_patterns = $purge_request->getHeader('X-Invalidate-Regexp')->toArray();
     $purge_pattern = reset($purge_patterns);
     return $purge_pattern;
 }
开发者ID:ec-europa,项目名称:platform-dev,代码行数:15,代码来源:FrontendCacheContext.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP predicate\equals函数代码示例发布时间:2022-05-23
下一篇:
PHP Translation\Translator类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap