コード例 #1
0
 /**
  * @test
  */
 public function instanceCreationThrowsBindingExceptionWhenNoPropertiesBound()
 {
     $injector = Binder::createInjector();
     expect(function () use($injector) {
         $injector->getInstance(PropertyReceiver::class);
     })->throws(BindingException::class)->message(startsWith('Can not inject into ' . PropertyReceiver::class . '::__construct($foo).' . ' No binding for type __PROPERTY__ (named "example.foo") specified.'));
 }
コード例 #2
0
 /**
  * @test
  */
 public function tellAfterCloseThrowsLogicException()
 {
     $this->standardInputStream->close();
     expect(function () {
         $this->standardInputStream->tell();
     })->throws(\LogicException::class);
 }
コード例 #3
0
 /**
  * @test
  */
 public function throwInvalidArgumentExceptionWhenTestValueIsNotOfTypeSequence()
 {
     $provides = Provides::values([]);
     expect(function () use($provides) {
         $provides->test(new \stdClass());
     })->throws(\InvalidArgumentException::class)->withMessage('Given value of type "object" is not an instance of ' . Sequence::class);
 }
コード例 #4
0
 /**
  * @test
  */
 public function constructionWithObjectThrowsIllegalArgumentException()
 {
     $value = value('foo');
     expect(function () use($value) {
         $value->equals(new \stdClass());
     })->throws(\InvalidArgumentException::class);
 }
コード例 #5
0
 /**
  * @test
  */
 public function injectWithInvalidProviderClassThrowsException()
 {
     $binder = new Binder();
     $binder->bind(Answer::class)->toProviderClass(\stdClass::class);
     $injector = $binder->getInjector();
     expect(function () use($injector) {
         $injector->getInstance(AnotherQuestion::class);
     })->throws(BindingException::class);
 }
コード例 #6
0
ファイル: RuntimeTest.php プロジェクト: stubbles/stubbles-ioc
 /**
  * @test
  * @since  4.0.0
  */
 public function createWithNonEnvironmentThrowsIllegalArgumentException()
 {
     expect(function () {
         new Runtime(new \stdClass());
     })->throws(\InvalidArgumentException::class);
 }
コード例 #7
0
ファイル: StreamTest.php プロジェクト: stubbles/stubbles-peer
 /**
  * @test
  */
 public function createWithInvalidResourceThrowsIllegalArgumentException()
 {
     expect(function () {
         new Stream('foo');
     })->throws(\InvalidArgumentException::class);
 }
コード例 #8
0
 /**
  * @since   2.0.0
  * @test
  * @dataProvider  invalidHttpVersions
  */
 public function deleteWithInvalidHttpVersionThrowsIllegalArgumentException($httpVersion)
 {
     expect(function () use($httpVersion) {
         $this->createHttpRequest()->delete(5, $httpVersion);
     })->throws(\InvalidArgumentException::class);
 }
コード例 #9
0
 /**
  * @test
  */
 public function typedMapWithInvalidValueThrowsBindingException()
 {
     $binder = new Binder();
     $binder->bindList('listConfig');
     $binder->bindMap('mapConfig');
     $binder->bindMap(Plugin::class)->withEntry('tb', 303);
     expect(function () use($binder) {
         $this->createPluginHandler($binder);
     })->throws(BindingException::class);
 }
コード例 #10
0
 /**
  * @test
  * @since  5.4.0
  */
 public function requestSessionScopedWithoutSessionThrowsRuntimeException()
 {
     expect(function () {
         $this->injector->getInstance(Person2::class);
     })->throws(\RuntimeException::class);
 }
コード例 #11
0
ファイル: AppTest.php プロジェクト: stubbles/stubbles-ioc
 /**
  * @test
  */
 public function invalidBindingModuleThrowsIllegalArgumentException()
 {
     expect(function () {
         App::createInstance(AppClassWithInvalidBindingModule::class, 'projectPath');
     })->throws(\InvalidArgumentException::class);
 }
コード例 #12
0
ファイル: HttpTest.php プロジェクト: stubbles/stubbles-peer
 /**
  * @test
  */
 public function getReasonPhraseForUnknownStatusCodeThrowsIllegalArgumentException()
 {
     expect(function () {
         Http::reasonPhraseFor(1);
     })->throws(\InvalidArgumentException::class);
 }
コード例 #13
0
 /**
  * @test
  * @since  5.3.0
  */
 public function throwsInvalidArgumentExceptionWhenBothValueMapperAndKeyMapperAreNull()
 {
     expect(function () {
         new MappingIterator(new \ArrayIterator(['foo', 'bar', 'baz']));
     })->throws(\InvalidArgumentException::class);
 }
コード例 #14
0
 /**
  * @test
  */
 public function throwsRuntimeExceptionWhenCreatedWithoutSession()
 {
     expect(function () {
         $this->sessionScope->getInstance(reflect(\stdClass::class), $this->provider);
     })->throws(\RuntimeException::class);
 }
コード例 #15
0
 /**
  * @test
  */
 public function missingConstantBindingOnInjectionHandlingThrowsBindingException()
 {
     $injector = Binder::createInjector();
     expect(function () use($injector) {
         $injector->getInstance(MissingArrayInjection::class);
     })->throws(BindingException::class);
 }
コード例 #16
0
 /**
  * @test
  */
 public function writeLineToExternalClosedStreamThrowsIOException()
 {
     fclose($this->handle);
     expect(function () {
         $this->resourceOutputStream->writeLine('foobarbaz');
     })->throws(StreamException::class);
 }
コード例 #17
0
 /**
  * @test
  */
 public function addAcceptableWithPriorityGreaterThan1ThrowsIllegalArgumentException()
 {
     expect(function () {
         $this->acceptHeader->addAcceptable('text/html', 1.1);
     })->throws(\InvalidArgumentException::class);
 }
コード例 #18
0
 /**
  * @test
  * @since  6.0.0
  */
 public function throwsBindingExceptionWhenNoFallbackSpecifiedAndNoModeSet()
 {
     $injector = Binder::createInjector();
     expect(function () use($injector) {
         $injector->getInstance(Person4::class);
     })->throws(BindingException::class);
 }
コード例 #19
0
 /**
  * @test
  */
 public function tellOnClosedStreamThrowsIllegalStateException()
 {
     $fileInputStream = new FileInputStream(vfsStream::url('home/test.txt'));
     $fileInputStream->close();
     expect(function () use($fileInputStream) {
         $fileInputStream->tell();
     })->throws(\LogicException::class);
 }
コード例 #20
0
 /**
  * @test
  * @since  5.0.0
  */
 public function asClassWithNonExistingClassAndDefaultThrowsReflectionException()
 {
     $parse = new Parse('does\\not\\Exist.class');
     expect(function () use($parse) {
         $parse->defaultingTo(__CLASS__ . '.class')->asClass();
     })->throws(\ReflectionException::class);
 }
コード例 #21
0
 /**
  * @since  2.1.0
  * @test
  * @group  issue_31
  */
 public function invalidObjectFromClosureAddedToTypedListThrowsBindingException()
 {
     $listBinding = $this->listBinding->withValueFromClosure(function () {
         return new \stdClass();
     });
     expect(function () use($listBinding) {
         $listBinding->getInstance($this->injector, new \ReflectionClass(InjectionProvider::class));
     })->throws(BindingException::class);
 }
コード例 #22
0
 /**
  * @test
  */
 public function throwsBindingExceptionWhenPropertyNotSet()
 {
     $properyBinding = $this->createPropertyBinding();
     expect(function () use($properyBinding) {
         $properyBinding->getInstance($this->injector, 'does.not.exist');
     })->throws(BindingException::class)->withMessage('Missing property does.not.exist for environment PROD');
 }
コード例 #23
0
 /**
  * @test
  */
 public function registerErrorHandlerWithInvalidClassThrowsIllegalArgumentException()
 {
     expect(function () {
         $this->environment->useErrorHandler(404);
     })->throws(\InvalidArgumentException::class);
 }
コード例 #24
0
 /**
  * @test
  * @dataProvider  emptyVersions
  */
 public function castFromEmptyWithoutDefaultThrowsIllegalArgumentException($empty)
 {
     expect(function () use($empty) {
         HttpVersion::castFrom($empty);
     })->throws(\InvalidArgumentException::class)->withMessage('Given HTTP version is empty');
 }
コード例 #25
0
 /**
  * @test
  */
 public function addIllegalParamThrowsIllegalArgumentException()
 {
     expect(function () {
         $this->emptyQueryString->addParam('some', new \stdClass());
     })->throws(\InvalidArgumentException::class);
 }
コード例 #26
0
 /**
  * @test
  * @group  ioc_constantprovider
  * @since  1.6.0
  */
 public function constantViaInvalidInjectionProviderClassThrowsBindingException()
 {
     $binder = new Binder();
     $binder->bindConstant('answer')->toProviderClass('\\stdClass');
     expect(function () use($binder) {
         $binder->getInjector()->getConstant('answer');
     })->throws(BindingException::class);
 }
コード例 #27
0
 /**
  * @test
  */
 public function putObjectThrowsIllegalArgumentException()
 {
     expect(function () {
         $this->headerList->put('Binford', new \stdClass());
     })->throws(\InvalidArgumentException::class);
 }
コード例 #28
0
 /**
  * @test
  */
 public function invalidRegexThrowsRuntimeExceptionOnEvaluation()
 {
     expect(function () {
         pattern('^([a-z]{3})$')->matches('foo');
     })->throws(\RuntimeException::class)->withMessage('Failure while matching "^([a-z]{3})$", reason: invalid regular expression.');
 }
コード例 #29
0
 /**
  * @test
  * @since  8.0.0
  */
 public function annotationNameWithInvalidCharactersThrowsReflectionException()
 {
     expect(function () {
         $this->parser->parse('/**
  * a method with an annotation for its parameter
  *
  * @1
  */', 'Bar::someMethod()');
     })->throws(\ReflectionException::class)->withMessage('Annotation name for Bar::someMethod()@ must start with a' . ' letter or underscore and may contain letters, underscores' . ' and numbers, but contains an invalid character: @1');
 }