Skip to content

Commit

Permalink
Merge pull request #10216 from ADmad/view-table-getter
Browse files Browse the repository at this point in the history
View, table getter
  • Loading branch information
ADmad committed Feb 14, 2017
2 parents 423489e + 6fde985 commit a327e83
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/ORM/Behavior.php
Expand Up @@ -179,6 +179,16 @@ public function initialize(array $config)
{
}

/**
* Get the table instance this behavior is bound to.
*
* @return \Cake\ORM\Table The bound table instance.
*/
public function getTable()
{
return $this->_table;
}

/**
* Removes aliased methods that would otherwise be duplicated by userland configuration.
*
Expand Down
10 changes: 10 additions & 0 deletions src/View/Helper.php
Expand Up @@ -155,6 +155,16 @@ public function __get($name)
}
}

/**
* Get the view instance this helper is bound to.
*
* @return \Cake\View\View The bound view instance.
*/
public function getView()
{
return $this->_View;
}

/**
* Returns a string to be used as onclick handler for confirm dialogs.
*
Expand Down
13 changes: 13 additions & 0 deletions tests/TestCase/ORM/BehaviorTest.php
Expand Up @@ -196,6 +196,19 @@ public function testConstructor()
$this->assertEquals($config, $behavior->config());
}

/**
* Test getting table instance.
*
* @return void
*/
public function testGetTable()
{
$table = $this->getMockBuilder('Cake\ORM\Table')->getMock();

$behavior = new TestBehavior($table);
$this->assertSame($table, $behavior->getTable());
}

public function testReflectionCache()
{
$table = $this->getMockBuilder('Cake\ORM\Table')->getMock();
Expand Down
11 changes: 11 additions & 0 deletions tests/TestCase/View/HelperTest.php
Expand Up @@ -150,6 +150,17 @@ public function testLazyLoadingUsesReferences()
$this->assertEquals($resultA->testprop, $resultB->testprop);
}

/**
* test getting view instance
*
* @return void
*/
public function testGetView()
{
$Helper = new TestHelper($this->View);
$this->assertSame($this->View, $Helper->getView());
}

/**
* Tests __debugInfo
*
Expand Down

0 comments on commit a327e83

Please sign in to comment.