1

before testing all my models in Cakephp app using ./cake test app AllModel I have to do some manipulations. I use Cakephp 2.9.7. This function is declared in AllModelTest.php which looks the next way:

class AllModelTest extends CakeTestSuite {
    public static function suite() {        
        $suite = new CakeTestSuite('All model tests');
        $suite->addTestDirectory(TESTS . 'Case/Model');
        return $suite;
    }
}

How can I access my Model and do some manipulations direct from this file ? I tried App::uses('MyModel', 'Model'); - that is not working. $this I can't use, because it gives me error PHP Fatal error: Using $this when not in object context in path....

handkock
  • 1,067
  • 2
  • 11
  • 23

2 Answers2

4

You can use ClassRegistry

$yourModel = ClassRegistry::init('YourModelName');
Bart
  • 1,268
  • 2
  • 12
  • 14
0

Just use ClassRegistry

$var = ClassRegistry::init("ModelName");
Riajul Islam
  • 1,425
  • 15
  • 19