Renaming methods so they are shorter and still make sense.

This commit is contained in:
mark_story 2011-09-21 22:32:39 -04:00
parent 82139fe8f6
commit b866c00318
2 changed files with 13 additions and 13 deletions

View file

@ -937,7 +937,7 @@ class ViewTest extends CakeTestCase {
echo 'Block content';
$this->View->end();
$result = $this->View->getBlock('test');
$result = $this->View->fetch('test');
$this->assertEquals('Block content', $result);
}
@ -955,7 +955,7 @@ class ViewTest extends CakeTestCase {
echo ' content';
$this->View->end();
$result = $this->View->getBlock('test');
$result = $this->View->fetch('test');
$this->assertEquals('Block content', $result);
}
@ -965,8 +965,8 @@ class ViewTest extends CakeTestCase {
* @return void
*/
public function testBlockSet() {
$this->View->setBlock('test', 'Block content');
$result = $this->View->getBlock('test');
$this->View->assign('test', 'Block content');
$result = $this->View->fetch('test');
$this->assertEquals('Block content', $result);
}
@ -976,10 +976,10 @@ class ViewTest extends CakeTestCase {
* @return void
*/
public function testBlockAppend() {
$this->View->setBlock('test', 'Block');
$this->View->assign('test', 'Block');
$this->View->append('test', ' content');
$result = $this->View->getBlock('test');
$result = $this->View->fetch('test');
$this->assertEquals('Block content', $result);
}
@ -990,7 +990,7 @@ class ViewTest extends CakeTestCase {
*/
public function testBlockAppendUndefined() {
$this->View->append('test', 'Unknown');
$result = $this->View->getBlock('test');
$result = $this->View->fetch('test');
$this->assertEquals('Unknown', $result);
}
@ -1001,7 +1001,7 @@ class ViewTest extends CakeTestCase {
* @return void
*/
public function testBlockSetArrayException() {
$this->View->setBlock('test', array(1, 2, 3));
$this->View->assign('test', array(1, 2, 3));
}
/**
@ -1021,7 +1021,7 @@ class ViewTest extends CakeTestCase {
*/
public function testBlocks() {
$this->View->append('test', 'one');
$this->View->setBlock('test1', 'one');
$this->View->assign('test1', 'one');
$this->assertEquals(array('test', 'test1'), $this->View->blocks());
}

View file

@ -568,20 +568,20 @@ class View extends Object {
* @return void
* @throws CakeException when you use non-string values.
*/
public function setBlock($name, $value) {
public function assign($name, $value) {
if (!is_string($value)) {
throw new CakeException(__d('cake_dev', 'You can only append strings.'));
throw new CakeException(__d('cake_dev', 'Blocks can only contain strings.'));
}
$this->_blocks[$name] = $value;
}
/**
* Get the content for a block.
* Fetch the content for a block.
*
* @param string $name Name of the block
* @return The block content or '' if the block does not exist.
*/
public function getBlock($name) {
public function fetch($name) {
if (!isset($this->_blocks[$name])) {
return '';
}