[Argil-svn] SF.net SVN: argil: [539] branches/experimental
Status: Alpha
Brought to you by:
tswicegood
|
From: <tsw...@us...> - 2007-05-30 21:11:14
|
Revision: 539
http://argil.svn.sourceforge.net/argil/?rev=539&view=rev
Author: tswicegood
Date: 2007-05-30 14:11:16 -0700 (Wed, 30 May 2007)
Log Message:
-----------
Adds the ability for @primaryKey to allow multi-column keys
Modified Paths:
--------------
branches/experimental/src/Argil/Reflection/Object.php
branches/experimental/tests/Argil/Reflection/ObjectTest.php
Modified: branches/experimental/src/Argil/Reflection/Object.php
===================================================================
--- branches/experimental/src/Argil/Reflection/Object.php 2007-05-30 20:58:12 UTC (rev 538)
+++ branches/experimental/src/Argil/Reflection/Object.php 2007-05-30 21:11:16 UTC (rev 539)
@@ -48,6 +48,7 @@
return '';
}
- return array_shift($collection->filter('primaryKey')->current()->params);
+ $keys = $collection->filter('primaryKey')->current()->params;
+ return ((count($keys) == 1) ? array_shift($keys) : $keys);
}
}
Modified: branches/experimental/tests/Argil/Reflection/ObjectTest.php
===================================================================
--- branches/experimental/tests/Argil/Reflection/ObjectTest.php 2007-05-30 20:58:12 UTC (rev 538)
+++ branches/experimental/tests/Argil/Reflection/ObjectTest.php 2007-05-30 21:11:16 UTC (rev 539)
@@ -18,6 +18,11 @@
*/
class ArgilSampleReflectionObjectWithPrimaryKey { }
+/**
+ * @primaryKey col1 col2
+ */
+class ArgilSampleReflectionObjectWithCompoundPrimaryKey { }
+
class Argil_Reflection_ObjectTest extends UnitTestCase
{
public function testReturnsArrayOfProperties()
@@ -63,4 +68,12 @@
$reflection = new Argil_Reflection_Object($this);
$this->assertEqual('', $reflection->getPrimaryKey());
}
+
+ public function testReturnsAnArrayForMultiColumnPrimaryKeys()
+ {
+ $reflection = new Argil_Reflection_Object(
+ new ArgilSampleReflectionObjectWithCompoundPrimaryKey()
+ );
+ $this->assertEqual(array('col1', 'col2'), $reflection->getPrimaryKey());
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|