Browse Source

Add test for loadModel() exception.

ADmad 7 years ago
parent
commit
824d41e5f5
1 changed files with 18 additions and 0 deletions
  1. 18 0
      tests/TestCase/Datasource/ModelAwareTraitTest.php

+ 18 - 0
tests/TestCase/Datasource/ModelAwareTraitTest.php

@@ -64,6 +64,24 @@ class ModelAwareTraitTest extends TestCase
     }
 
     /**
+     * Test that calling loadModel() without $modelClass argument when default
+     * $modelClass property is empty generates exception.
+     *
+     * @return void
+     */
+    public function testLoadModelException()
+    {
+        $this->expectException(\UnexpectedValueException::class);
+        $this->expectExceptionMessage('Default modelClass is empty');
+
+        $stub = new Stub();
+        $stub->setProps('');
+        $stub->setModelType('Table');
+
+        $stub->loadModel();
+    }
+
+    /**
      * test loadModel() with plugin prefixed models
      *
      * Load model should not be called with Foo.Model Bar.Model Model