Skip to content

Commit

Permalink
bugfixes, added test for tumblr redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Jun 18, 2018
1 parent 28e14bf commit 46e1980
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 15 deletions.
5 changes: 4 additions & 1 deletion src/Adapters/Howcast.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ public function getCode()
$this->width = null;
$this->height = null;

$dom = $this->getResponse()->getHtmlContent();
if (!($dom = $this->getResponse()->getHtmlContent())) {
return;
}

// #embedModal textarea
$textarea = Utils::xpathQuery($dom, "descendant-or-self::*[@id = 'embedModal']/descendant-or-self::*/textarea");

Expand Down
2 changes: 1 addition & 1 deletion src/Providers/OEmbed/DOM.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static function create(Adapter $adapter)
*
* @param Response $response
*/
public function __construct(Response $response)
protected function __construct(Response $response)
{
$this->response = $response;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Providers/OEmbed/Embedly.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static function create(Adapter $adapter)
* @param Response $response
* @param string $key
*/
private function __construct(Response $response, $key)
protected function __construct(Response $response, $key)
{
$this->response = $response;
$this->key = $key;
Expand Down
2 changes: 1 addition & 1 deletion src/Providers/OEmbed/EndPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static function create(Adapter $adapter)
*
* @param Response $response
*/
private function __construct(Response $response)
protected function __construct(Response $response)
{
$this->response = $response;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Providers/OEmbed/Iframely.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static function create(Adapter $adapter)
* @param Response $response
* @param string $key
*/
private function __construct(Response $response, $key)
protected function __construct(Response $response, $key)
{
$this->response = $response;
$this->key = $key;
Expand Down
11 changes: 1 addition & 10 deletions src/Providers/OEmbed/Tumblr.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,12 @@ class Tumblr extends EndPoint implements EndPointInterface
public static function create(Adapter $adapter)
{
$response = $adapter->getResponse();

if ($response->getStartingUrl()->match(static::$pattern)) {
return new static($response);
}
}

/**
* Constructor.
*
* @param Response $response
*/
private function __construct(Response $response)
{
$this->response = $response;
}

/**
* {@inheritdoc}
*/
Expand Down
11 changes: 11 additions & 0 deletions tests/TumblrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,15 @@ public function testOne()
]
);
}

public function testRedirect()
{
$this->assertEmbed(
'https://t.umblr.com/redirect?z=https%3A%2F%2Fcm.engineering%2Fhow-to-test-accessibility-of-emails-b68fed03f5f4&t=YmJlOWJlMDE2MTBhNjgzMGQ3OWI4YjcyYTc3ZGVmODVlMjQxZWU0OCxEMHp1MXlSVg%3D%3D&b=t%3ABS0dIKxiGtP4rIANih2MqA&p=http%3A%2F%2Ftoday.uxdesign.cc%2Fpost%2F174967774408%2Fhow-to-test-accessibility-of-emails',
[
'title' => 'How to test accessibility of emails – Campaign Monitor Engineering',
'url' => 'https://cm.engineering/how-to-test-accessibility-of-emails-b68fed03f5f4',
]
);
}
}

0 comments on commit 46e1980

Please sign in to comment.