setApi() публичный Метод

Set the api configuration name.
public setApi ( string $api )
$api string Api configuration name.
Пример #1
0
 public function testGetCallbackResultException()
 {
     $methodData = ['method' => 'testCallbackException', 'cache' => ['ttl' => 0], 'header' => ['cache' => ['expires' => 0], 'status' => ['success' => 200, 'error' => 404, 'errorMessage' => '']]];
     $requestBag = new RequestBag();
     $requestBag->setApi('CacheTest')->setClassData(['class' => 'Webiny\\Component\\Rest\\Tests\\Mocks\\MockApiClassCallback', 'version' => '1.0'])->setMethodData($methodData)->setMethodParameters([]);
     $callback = new Callback($requestBag);
     $response = $callback->getCallbackResult()->getOutput();
     $this->assertSame('There has been an error processing the request.', $response['errorReport']['message']);
 }
Пример #2
0
 public function testPurgeResult()
 {
     $requestBag = new RequestBag();
     // populate request bag and point the cache key creation to the mocked class
     $requestBag->setApi('CacheTest')->setMethodData(['cache' => ['ttl' => 100]])->setClassInstance(new MockCacheTestApiClass())->setClassData(['cacheKeyInterface' => true]);
     \Webiny\Component\Rest\Response\Cache::saveResult($requestBag, 'my result');
     $result = \Webiny\Component\Rest\Response\Cache::getFromCache($requestBag);
     $this->assertSame('my result', $result);
     \Webiny\Component\Rest\Response\Cache::purgeResult($requestBag);
     $result = \Webiny\Component\Rest\Response\Cache::getFromCache($requestBag);
     $this->assertFalse($result);
 }
Пример #3
0
 public function testSetGetApi()
 {
     $rb = new RequestBag();
     $rb->setApi('ExampleApi');
     $this->assertSame('ExampleApi', $rb->getApi());
 }