Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

View, table getter #10216

Merged
merged 2 commits into from Feb 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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