Skip to content
Permalink
Browse files

Add setUrl convenience method to SeoHelper

  • Loading branch information
trvrnrth committed Apr 3, 2019
1 parent a73ef47 commit 237bd3fa875e08ec98d3346a11155389e6e10af7
Showing with 32 additions and 0 deletions.
  1. +15 −0 src/SeoHelper.php
  2. +17 −0 tests/SeoHelperTest.php
@@ -253,6 +253,21 @@ public function setImage($imageUrl)
return $this;
}
/**
* Set the current URL.
*
* @param string $url
*
* @return \Arcanedev\SeoHelper\SeoHelper
*/
public function setUrl($url)
{
$this->meta()->setUrl($url);
$this->openGraph()->setUrl($url);
return $this;
}
/* -----------------------------------------------------------------
| Main Methods
| -----------------------------------------------------------------
@@ -229,6 +229,23 @@ public function it_can_set_and_render_image()
static::assertStringContainsString($expected, $rendered);
}
}
/** @test */
public function it_can_set_and_render_url()
{
$this->seoHelper->setUrl($url = 'http://localhost/path');
$expectations = [
'<link rel="canonical" href="'.$url.'">',
'<meta property="og:url" content="'.$url.'">'
];
$rendered = $this->seoHelper->render();
foreach ($expectations as $expected) {
static::assertStringContainsString($expected, $rendered);
}
}
/** @test */
public function it_can_render_all()

0 comments on commit 237bd3f

Please sign in to comment.
You can’t perform that action at this time.