Browse Source

Unit testing Entity after adding the source() method

Jose Lorenzo Rodriguez 12 years ago
parent
commit
24b28af3b3
1 changed files with 26 additions and 3 deletions
  1. 26 3
      tests/TestCase/ORM/EntityTest.php

+ 26 - 3
tests/TestCase/ORM/EntityTest.php

@@ -1005,16 +1005,39 @@ class EntityTest extends TestCase {
 		$entity = new Entity(['foo' => 'bar'], ['markClean' => true]);
 		$entity->accessible('name', true);
 		$entity->virtualProperties(['baz']);
+		$entity->dirty('foo', true);
 		$entity->errors('foo', ['An error']);
+		$entity->source([
+			'alias' => 'foos',
+			'className' => 'Something'
+		]);
 		$result = $entity->__debugInfo();
 		$expected = [
-			'new' => true,
-			'accessible' => ['name'],
+			'new' => null,
+			'accessible' => ['name' => true],
 			'properties' => ['foo' => 'bar'],
 			'dirty' => ['foo' => true],
 			'virtual' => ['baz'],
-			'errors' => ['foo' => ['An error']]
+			'errors' => ['foo' => ['An error']],
+			'repository' => [
+				'alias' => 'foos',
+				'className' => 'Something'
+			]
 		];
+		$this->assertSame($expected, $result);
+	}
+
+/**
+ * Tests the source method
+ *
+ * @return void
+ */
+	public function testSource() {
+		$entity = new Entity;
+		$this->assertEquals([], $entity->source());
+		$source = ['alias' => 'foo', 'className' => 'bar'];
+		$entity->source($source);
+		$this->assertEquals($source, $entity->source());
 	}
 
 }