/** * Test that we can create a SemRush result */ public function testCreate() { $columns = ["Db", "Dn", "Rk", "Or", "Ot", "Oc", "Ad", "At", "Ac"]; $values = "us;seobook.com;29062;3214;33696;193957;0;0;0"; $data = array_combine($columns, explode(";", $values)); $result = $this->instance->create([$data, $data]); $this->assertTrue($result instanceof Result); $this->assertEquals(2, count($result)); foreach ($result as $row) { $this->assertTrue($row instanceof Row); } }
/** * Make the request * * @param string $type * @param array $options * @return ApiResult */ protected function makeRequest($type, $options) { $request = $this->requestFactory->create($type, ['key' => $this->apiKey] + $options); // Attempt load from cache if (isset($this->cache)) { $result = $this->cache->fetch($request); } // Make request if not in cache if (!isset($result)) { $rawResponse = $this->makeHttpRequest($request); $formattedResponse = $this->responseParser->parseResult($request, $rawResponse); $result = $this->resultFactory->create($formattedResponse); } // Save to cache if (isset($this->cache)) { $this->cache->cache($request, $result); } return $result; }