Skip to content

Commit

Permalink
don't expose $content property
Browse files Browse the repository at this point in the history
  • Loading branch information
omarreiss committed Sep 30, 2014
1 parent 86ccba3 commit 80be765
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion admin/class-metabox.php
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ function snippet() {

$snippet_preview = new WPSEO_Snippet_Preview( $post, $title, $description );

return $snippet_preview->content;
return $snippet_preview->get_content();
}

/**
Expand Down
10 changes: 9 additions & 1 deletion admin/class-snippet-preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class WPSEO_Snippet_Preview {
/**
* The dynamically generated html for the snippet preview.
*/
public $content;
protected $content;

/**
* The WPSEO options.
Expand Down Expand Up @@ -68,6 +68,14 @@ public function __construct( $post, $title, $description ) {
$this->set_content();
}

/**
* Getter for $this->content
* @return string html for snippet preview
*/
public function get_content() {
return $this->content;
}

/**
* Sets date if available
*/
Expand Down
8 changes: 4 additions & 4 deletions tests/test-class-wpseo-snippet-preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class WPSEO_Snippet_Preview_Test extends WPSEO_UnitTestCase {
private $date;
private $url;

public function test_content_GIVEN_a_regular_post() {
public function test_get_content_GIVEN_a_regular_post() {
$this->post = $this->factory->post->create_and_get( array( 'post_title' => $this->title ) );
$this->date = $this->post->date;
$this->url = str_replace( 'http://', '', get_bloginfo( 'url' ) ) . '/';
Expand All @@ -22,10 +22,10 @@ public function test_content_GIVEN_a_regular_post() {
</div>
HTML;
$snippet_preview = new WPSEO_Snippet_Preview( $this->post, $this->title, $this->description );
$this->assertEquals( $expected, $snippet_preview->content );
$this->assertEquals( $expected, $snippet_preview->get_content() );
}

public function test_content_GIVEN_a_post_that_is_frontpage() {
public function test_get_content_GIVEN_a_post_that_is_frontpage() {
$this->post = $this->factory->post->create_and_get( array( 'post_title' => $this->title ) );
$this->date = $this->post->date;
$this->url = str_replace( 'http://', '', get_bloginfo( 'url' ) ) . '/';
Expand All @@ -41,6 +41,6 @@ public function test_content_GIVEN_a_post_that_is_frontpage() {
</div>
HTML;
$snippet_preview = new WPSEO_Snippet_Preview( $this->post, $this->title, $this->description );
$this->assertEquals( $expected, $snippet_preview->content );
$this->assertEquals( $expected, $snippet_preview->get_content() );
}
}

0 comments on commit 80be765

Please sign in to comment.