Browse Source

Fixnishing stub test case

Jose Lorenzo Rodriguez 10 years ago
parent
commit
7ca6baf510
1 changed files with 18 additions and 3 deletions
  1. 18 3
      tests/TestCase/ORM/BindingKeyTest.php

+ 18 - 3
tests/TestCase/ORM/BindingKeyTest.php

@@ -33,6 +33,11 @@ class BindingKeyTest extends TestCase
         'core.auth_users'
     ];
 
+    /**
+     * Tests that bindingKey can be used in belongsTo associations
+     *
+     * @return void
+     */
     public function testBelongsto()
     {
         $users = TableRegistry::get('Users');
@@ -43,8 +48,18 @@ class BindingKeyTest extends TestCase
 
         $result = $users->find()
             ->contain(['AuthUsers']);
-        debug($result);
-        debug($result->toArray());
-    }
 
+        $expected = ['mariano', 'nate', 'larry', 'garrett'];
+        $expected = array_combine($expected, $expected);
+        $this->assertEquals(
+            $expected,
+            $result->combine('username', 'auth_user.username')->toArray()
+        );
+
+        $expected = [1 => 1, 2 => 5, 3 => 2, 4 => 4];
+        $this->assertEquals(
+            $expected,
+            $result->combine('id', 'auth_user.id')->toArray()
+        );
+    }
 }