cakePHP3環境でPHPunitを使ったコントローラーのテストを書いているのですが、ACL周りでエラーとなり困っています。
やりたい事
コントローラーを仮に「AbcController」とし、AbcControllerのindexメソッドに、権限のあるユーザーでログイン状態でアクセスしてテストを書こうとしています。コントローラーはAuth / ACLでアクセス権を管理しています。
###エラーメッセージ
1) App\Test\TestCase\Controller\AbcControllerTest::testIndex BadMethodCallException: Unknown method "node"
試した事
テストで書いた内容
php
1 2 Fabricate::config(function ($config) { 3 $config->adaptor = new CakeFabricateAdaptor(); 4 }); 5 6 // acl設定追加 7 Fabricate::create('Aros', ['id' => 1, 'parent_id' => null, 'model' => 'Groups', 'foreign_key' => 1, 'alias' => null, 'lft' => 1, 'rght' => 2]); 8 Fabricate::create('Aros', ['id' => 2, 'parent_id' => null, 'model' => 'Users', 'foreign_key' => 1, 'alias' => null, 'lft' => 1, 'rght' => 2]); 9 Fabricate::create('Acos', ['id' => 1, 'parent_id' => null, 'model' => 'Groups', 'foreign_key' => 1, 'alias' => null, 'lft' => 1, 'rght' => 2]); 10 Fabricate::create('Acos', ['id' => 2, 'parent_id' => null, 'model' => 'Users', 'foreign_key' => 1, 'alias' => null, 'lft' => 1, 'rght' => 2]); 11 Fabricate::create('ArosAcos', ['id' => 1, 'aro_id' => 1, 'aco_id' => 1, '_create' => '', '_read' => '', '_update' => '', '_delete' => '']); 12 Fabricate::create('ArosAcos', ['id' => 2, 'aro_id' => 2, 'aco_id' => 2, '_create' => '', '_read' => '', '_update' => '', '_delete' => '']); 13 14 // ユーザー追加 15 Fabricate::create('Users', [ 16 'id' => 1, 17 'username' => 'hoge', 18 'password' => 'boo', 19 'group_id' => 1 20 ]); 21 22 // ログイン 23 $this->post('login', [ 24 'username' => 'hoge', 25 'password' => 'boo', 26 ]); 27 $this->session($this->_requestSession->read()); 28 29 // アクセス 30 $this->get('abc');
これを走らせるとユーザーを追加している箇所で上記エラーメッセージとなりました。
ACLについて日が浅く、どういった点に注意すべきかもわからない状態です。
問題点がどこかご指摘頂けますと助かります。よろしくお願いいたします。
あなたの回答
tips
プレビュー