public function testResponse3() { $config = array('fake' => array('width' => 500, 'height' => 315, 'url' => 'http://hi.com', 'thumb' => 'http://image.com'), 'params' => array('maxwidth' => 210)); $response = array('provider_name' => 'a provider name', 'html' => '<div style="height:{height}px;width:{width}px">hi</div>'); $fakeResponse = new \Embera\FakeResponse($config, $response); $response = $fakeResponse->buildResponse(); $this->assertEquals($response['width'], 500); $this->assertEquals($response['height'], 315); $this->assertEquals($response['html'], '<div style="height:315px;width:500px">hi</div>'); $this->assertEquals($response['version'], '1.0'); $this->assertEquals($response['url'], 'http://hi.com'); $this->assertEquals($response['thumb'], 'http://image.com'); }
/** * Gets the information from an Oembed provider * when this fails, it tries to provide a fakeResponse. * Returns an associative array with a (common) Oembed response. * * @return array */ public function getInfo() { try { if ($res = $this->oembed->getResourceInfo($this->config['oembed'], $this->apiUrl, (string) $this->url, $this->config['params'])) { return $this->modifyResponse($res); } } catch (\Exception $e) { $this->errors[] = $e->getMessage(); } /** * Use fakeResponses when the oembed setting is null or false * If the oembed config is true, the user strictly wants real responses */ if (!$this->config['oembed'] && ($response = $this->fakeResponse())) { $fakeResponse = new \Embera\FakeResponse($this->config, $response); return $this->modifyResponse($fakeResponse->buildResponse()); } return array(); }