Skip to content

Commit

Permalink
Test Open Graph Tags Generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
francis94c committed Jul 2, 2019
1 parent bef2081 commit 355b9e3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion libraries/Blogger.php
Expand Up @@ -405,7 +405,7 @@ public function metaOg(array $post): string {
$data["description"] = substr($post["content"], 0, 154);
if (isset($post["share_image"])) $data["image_link"] = $post["share_image"];
$data["url"] = current_url();
// Load Meta OG view.
// Return Meta OG View String.
return $this->ci->load->splint(self::PACKAGE, "-meta_og", $data, true);
}
/**
Expand Down
20 changes: 18 additions & 2 deletions unit_tests/BlogTest.php
Expand Up @@ -319,7 +319,7 @@ public function testRenderPost(): void {
/**
* Test Posts Vount and Blog Delete.
*
* @testdox Test Posts Count and Blog Delete.
* @testdox Test Posts Count and Blog Delete.
*
* @depends testRenderPost
*/
Expand All @@ -334,6 +334,22 @@ public function testPostCountAndPostDelete(): void {
$this->assertEquals(Blogger::DELETE, self::$ci->blogger->savePost(1));
$this->assertEquals(2, self::$ci->blogger->getPostsCount(false));
}
/**
* Test Meta OG
*
*@depends testPostCountAndPostDelete
*
* @testdox Test Open Graph Tags Generation. √
*/
public function testMetaOG(): void {
$post = self::$ci->blogger->getPost("Admin-Hello-Title", false);
$og = self::$ci->blogger->metaOg($post);
$this->assertRegExp("/<meta name=\"description\" content=\"The Quick Brown Fox Jumped over the Lazy Dog. Again.\">/", $og);
$this->assertRegExp("/<meta property=\"og:title\" content=\"Admin Hello Title\">/", $og);
$this->assertRegExp("/<meta property=\"og:description\" content=\"The Quick Brown Fox Jumped over the Lazy Dog. Again.\">/", $og);
$this->assertRegExp("/<meta property=\"og:image\" content=\"\">/", $og);
$this->assertRegExp("/<meta name=\"twitter:card\" content=\"summary_large_image\">/", $og);
}
/**
* Test No Action
*
Expand Down Expand Up @@ -361,7 +377,7 @@ public function testRenderPostItems(): void {

$this->assertRegExp("/A CARD HERE Admin Hello Title TOKEN <p>The Quick Brown Fox Jumped over the Lazy Dog. Again.<\/p> ID = 1/", $o);
$this->assertRegExp("/A CARD HERE Admin Hello Title 2 TOKEN <p>Create and Published Post.<\/p> ID = 2/", $o);
$this->assertRegExp("/the_gunners/", $o);
$this->assertRegExp("/the_gunners/", $o);
}
/**
* Test Setters and Getters.
Expand Down

0 comments on commit 355b9e3

Please sign in to comment.