Skip to content

Commit

Permalink
Make View::$hasRendered protected as add getter method for it.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Jun 6, 2018
1 parent 1462dde commit 0f15196
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/View/View.php
Expand Up @@ -191,7 +191,7 @@ class View implements EventDispatcherInterface
*
* @var bool
*/
public $hasRendered = false;
protected $hasRendered = false;

/**
* List of generated DOM UUIDs.
Expand Down Expand Up @@ -1394,6 +1394,16 @@ public function loadHelper($name, array $config = [])
return $this->{$class} = $helpers->load($name, $config);
}

/**
* Check whether the view has been rendered.
*
* @return bool
*/
public function hasRendered()
{
return $this->hasRendered;
}

/**
* Returns filename of given action's template file (.ctp) as a string.
* CamelCased action names will be under_scored by default.
Expand Down
13 changes: 13 additions & 0 deletions tests/TestCase/View/ViewTest.php
Expand Up @@ -2135,6 +2135,19 @@ public function testGetSetLayout()
$this->assertSame($layout, 'foo');
}

/**
* Test testHasRendered()
*
* @return void
*/
public function testHasRendered()
{
$this->assertFalse($this->View->hasRendered());

$this->View->render('index');
$this->assertTrue($this->View->hasRendered());
}

/**
* Test magic getter and setter for removed properties.
*
Expand Down

0 comments on commit 0f15196

Please sign in to comment.