Пример #1
0
 /**
  * @test
  */
 public function createNewDocumentOnSave()
 {
     $id = 1;
     $data = 'foobar';
     $this->prophesizeGetDocumentThrowsException($id);
     $this->index->refresh()->shouldBeCalled();
     $doc = $this->getDocument($id, $data);
     $this->type->createDocument($this->getCacheId($id), [Cache::VALUE_FIELD => serialize($data)])->shouldBeCalled()->willReturn($doc);
     $this->type->addDocument($doc)->shouldBeCalled();
     self::assertTrue($this->cache->save($id, $data));
 }
 /**
  * @test
  */
 public function provideCorrectTokenUpdatesExpirationAndFallbacksToNextMiddleware()
 {
     $authToken = 'ABC-abc';
     $request = ServerRequestFactory::fromGlobals()->withAttribute(RouteResult::class, RouteResult::fromRouteMatch('bar', 'foo', []))->withHeader(CheckAuthenticationMiddleware::AUTHORIZATION_HEADER, 'bearer ' . $authToken);
     $this->jwtService->verify($authToken)->willReturn(true)->shouldBeCalledTimes(1);
     $this->jwtService->refresh($authToken)->willReturn($authToken)->shouldBeCalledTimes(1);
     $isCalled = false;
     $this->assertFalse($isCalled);
     $this->middleware->__invoke($request, new Response(), function ($req, $resp) use(&$isCalled) {
         $isCalled = true;
         return $resp;
     });
     $this->assertTrue($isCalled);
 }