當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。