Browse Source

Merge pull request #17622 from cakephp/5.x-behavior-load

Add test case for behavior loading.
Mark Story 2 years ago
parent
commit
6d7a0cfb2e
1 changed files with 15 additions and 0 deletions
  1. 15 0
      tests/TestCase/ORM/TableTest.php

+ 15 - 0
tests/TestCase/ORM/TableTest.php

@@ -1903,6 +1903,21 @@ class TableTest extends TestCase
     }
 
     /**
+     * Test adding a plugin behavior to a table.
+     */
+    public function testAddBehaviorPlugin(): void
+    {
+        $table = new Table([
+            'table' => 'articles',
+        ]);
+        $result = $table->addBehavior('TestPlugin.PersisterOne', ['some' => 'key']);
+
+        $this->assertSame(['PersisterOne'], $result->behaviors()->loaded());
+        $className = $result->behaviors()->get('PersisterOne')->getConfig('className');
+        $this->assertSame('TestPlugin.PersisterOne', $className);
+    }
+
+    /**
      * Test adding a behavior that is a duplicate.
      */
     public function testAddBehaviorDuplicate(): void