コード例 #1
0
 /**
  * @test
  */
 public function returnsInstanceFromSessionIfPresent()
 {
     $instance = new \stdClass();
     $this->prepareSession(['hasValue' => true, 'value' => $instance]);
     assert($this->sessionScope->getInstance(reflect(\stdClass::class), $this->provider), isSameAs($instance));
     verify($this->provider, 'get')->wasNeverCalled();
 }
コード例 #2
0
 /**
  * @test
  * @dataProvider  throwables
  */
 public function writesMessageAndTraceForInternalException($throwable)
 {
     $displayExceptionHandler = $this->createExceptionHandler('cgi');
     $displayExceptionHandler->handleException($throwable);
     verify($displayExceptionHandler, 'header')->received('Status: 500 Internal Server Error');
     verify($displayExceptionHandler, 'writeBody')->received("failure message\nTrace:\n" . $throwable->getTraceAsString());
 }
コード例 #3
0
 /**
  * @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']);
 }
コード例 #4
0
 /**
  * @test
  * @dataProvider  throwables
  */
 public function loggingDisabledFillsResponseOnly($throwable)
 {
     $this->exceptionHandler->disableLogging()->handleException($throwable);
     verify($this->exceptionHandler, 'header')->wasCalledOnce();
     verify($this->exceptionHandler, 'createResponseBody')->wasCalledOnce();
     verify($this->exceptionHandler, 'writeBody')->wasCalledOnce();
 }
コード例 #5
0
 /**
  * @test
  * @dataProvider  throwables
  */
 public function returnsContentOfError500FileIfPresent($throwable)
 {
     vfsStream::newFile('docroot/500.html')->withContent('An error occurred')->at($this->root);
     $prodModeExceptionHandler = $this->createExceptionHandler('apache');
     $prodModeExceptionHandler->handleException($throwable);
     verify($prodModeExceptionHandler, 'header')->received('HTTP/1.1 500 Internal Server Error');
     verify($prodModeExceptionHandler, 'writeBody')->received('An error occurred');
 }
コード例 #6
0
 /**
  * @test
  */
 public function injectWithProviderInstance()
 {
     $binder = new Binder();
     $answer = new Answer();
     $provider = NewInstance::of(InjectionProvider::class)->mapCalls(['get' => $answer]);
     $binder->bind(Answer::class)->toProvider($provider);
     $question = $binder->getInjector()->getInstance(AnotherQuestion::class);
     assert($question->getAnswer(), isSameAs($answer));
     verify($provider, 'get')->received('answer');
 }
コード例 #7
0
 /**
  * @test
  */
 public function handleSignalsResultOfResponsibleErrorHandlerIfErrorReportingDisabled()
 {
     $oldLevel = error_reporting(0);
     try {
         $this->errorHandler1->mapCalls(['isResponsible' => false]);
         $this->errorHandler2->mapCalls(['isResponsible' => true, 'isSupressable' => false, 'handle' => ErrorHandler::STOP_ERROR_HANDLING]);
         assert($this->errorHandlers->handle(1, 'foo'), equals(ErrorHandler::STOP_ERROR_HANDLING));
         verify($this->errorHandler3, 'isResponsible')->wasNeverCalled();
     } finally {
         error_reporting($oldLevel);
     }
 }
コード例 #8
0
 /**
  * @test
  */
 public function closeCallsDecoratedStream()
 {
     $inputStream = NewInstance::of(InputStream::class);
     $decoratedInputStream = $this->createDecoratedInputStream($inputStream);
     $decoratedInputStream->close();
     verify($inputStream, 'close')->wasCalledOnce();
 }
コード例 #9
0
 /**
  * @test
  */
 public function closeClosesDecoratedOutputStream()
 {
     $outputStream = NewInstance::of(OutputStream::class);
     $encodingOutputStream = new EncodingOutputStream($outputStream, 'iso-8859-1');
     $encodingOutputStream->close();
     verify($outputStream, 'close')->wasCalledOnce();
 }
コード例 #10
0
ファイル: UriTest.php プロジェクト: stubbles/stubbles-peer
 /**
  * @test
  * @group  bug258
  */
 public function hasDnsRecordForIpv6Localhost()
 {
     $checkdnsrr = NewCallable::of('checkdnsrr');
     assertTrue(Uri::fromString('http://[::1]')->hasDnsRecord($checkdnsrr));
     verify($checkdnsrr)->wasNeverCalled();
 }
コード例 #11
0
ファイル: RuntimeTest.php プロジェクト: stubbles/stubbles-ioc
 /**
  * @test
  * @since  3.4.0
  */
 public function bindsPropertiesWhenConfigFilePresent()
 {
     vfsStream::newFile('config/config.ini')->withContent("[config]\nstubbles.locale=\"de_DE\"\nstubbles.number.decimals=4\nstubbles.webapp.xml.serializeMode=true")->at($this->root);
     $binder = NewInstance::of(Binder::class);
     $runtime = new Runtime($this->environment);
     $runtime->configure($binder, $this->root->url());
     verify($binder, 'bindProperties')->wasCalledOnce();
 }
コード例 #12
0
 /**
  * @test
  */
 public function closeClosesDecoratedStream()
 {
     $inputStream = NewInstance::of(InputStream::class);
     $decodingInputStream = new DecodingInputStream($inputStream, 'iso-8859-1');
     $decodingInputStream->close();
     verify($inputStream, 'close')->wasCalledOnce();
 }