Hi, I am not able to create a test for my plugins component.
Component:
Test:
If I try to run the test I got the following error mesage:
Notice Error: Trying to get property of non-object in [/home/rrd/public_html/plugins/RBruteForce/src/Controller/Component/RBruteForceComponent.php, line 28]
Line 28 is:
It seems that $this->controller is not created.
Anyone has an idea what is wrong?
-- Component:
namespace RBruteForce\Controller\Component;
use Cake\Controller\Component;
use Cake\Routing\Router;
use Cake\ORM\TableRegistry;
class RBruteForceComponent extends Component {
public function initialize(array $config) {
$this->controller = $this->_registry->getController();
$this->request = $this->controller->request;
$this->response = $this->controller->response;
}
Test:
namespace RBruteForce\Test\TestCase\Controller\Component;
use RBruteForce\Controller\Component\RBruteForceComponent;
use Cake\TestSuite\TestCase;
use Cake\Controller\Controller;
use Cake\Controller\ComponentRegistry;
use Cake\Network\Request;
use Cake\Network\Response;
class RBruteForceComponentTest extends TestCase {
public $component = null;
public $controller = null;
public function setUp() {
parent::setUp();
// Setup our component and fake test controller
$collection = new ComponentRegistry();
$this->component = new RBruteForceComponent($collection);
$request = new Request();
$response = new Response();
$this->controller = $this->getMock(
'Cake\Controller\Controller',
[],
[$request, $response]
);
}
If I try to run the test I got the following error mesage:
Notice Error: Trying to get property of non-object in [/home/rrd/public_html/plugins/RBruteForce/src/Controller/Component/RBruteForceComponent.php, line 28]
Line 28 is:
$this->request = $this->controller->request;
It seems that $this->controller is not created.
Anyone has an idea what is wrong?
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment