Commit: 3dcaf18114b0e0a7f3da473f45d2dd28afc4637e
Author: gwoo | Date: 2010-01-24 09:48:12 -0800
diff --git a/models/Plugin.php b/models/Plugin.php
index e58ab02..204f9da 100644
--- a/models/Plugin.php
+++ b/models/Plugin.php
@@ -37,7 +37,10 @@ class Plugin extends \lithium\data\Model {
'name' => 'You must specify a name for this plugin.',
'version' => 'You must specify a version for this plugin.',
'summary' => 'You must specify a short summary for this plugin',
- 'sources' => array('isSource', 'message' => 'You must specify a source for this plugin.')
+ 'sources' => array(
+ 'isSource', 'types' => array('git', 'phar'),
+ 'message' => 'You must specify a source for this plugin.'
+ )
);
public static function __init($options = array()) {
@@ -52,11 +55,11 @@ class Plugin extends \lithium\data\Model {
return $chain->next($self, $params, $chain);
});
Validator::add('isSource', function ($data, $params, $options) {
- $types = array('git', 'phar');
foreach ($data as $type => $source) {
- if (in_array($type, $types)) {
+ if (in_array($type, $options['types'])) {
return true;
}
+ return false;
}
});
}
diff --git a/tests/cases/models/PluginTest.php b/tests/cases/models/PluginTest.php
index eaf11d9..b2dba9e 100644
--- a/tests/cases/models/PluginTest.php
+++ b/tests/cases/models/PluginTest.php
@@ -18,11 +18,6 @@ class PluginTest extends \lithium\test\Unit {
Connections::add('test_li3_lab', 'http', array('adapter' => 'CouchDb'));
}
- public function tearDown() {
- Connections::get('test_li3_lab')->delete(new Query());
-
- }
-
protected $_data = array(
'name' => 'li3_bot',
'version' => '0.3',
@@ -78,6 +73,8 @@ class PluginTest extends \lithium\test\Unit {
$expected = 'li3_bot';
$result = $plugin->name;
$this->assertEqual($expected, $result);
+
+ MockPlugin::create()->delete();
}
}