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


PHP assert\assert函数代码示例

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


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


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