Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Kr�mer committed Oct 29, 2012
2 parents 2de8e35 + 95434eb commit 0bf6246
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 44 deletions.
4 changes: 2 additions & 2 deletions Controller/Component/PrgComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function __construct(ComponentCollection $collection, $settings) {
}

/**
* Poplulates controller->data with allowed values from the named/passed get params
* Populates controller->data with allowed values from the named/passed get params
*
* Fields in $controller::$presetVars that have a type of 'lookup' the foreignKey value will be inserted
*
Expand Down Expand Up @@ -164,7 +164,7 @@ public function presetForm($options) {
}
}

if (in_array($field['type'], array('value', 'like'))) {
if (in_array($field['type'], array('value', 'like', 'query'))) {
if (isset($args[$field['field']])) {
$data[$model][$field['field']] = $args[$field['field']];
}
Expand Down
11 changes: 6 additions & 5 deletions Test/Case/AllSearchPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
*/
class AllSearchPluginTest extends PHPUnit_Framework_TestSuite {

/**
* suite method, defines tests for this suite.
*
* @return void
*/
/**
* suite method, defines tests for this suite.
*
* @return void
*/
public static function suite() {
$Suite = new CakeTestSuite('All Plugin tests');
$path = dirname(__FILE__);
$Suite->addTestDirectory($path . DS . 'Controller' . DS . 'Component');
$Suite->addTestDirectory($path . DS . 'Model' . DS . 'Behavior');
return $Suite;
}

}
12 changes: 6 additions & 6 deletions Test/Case/Controller/Component/PrgComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function beforeFilter() {
* @param string $exit
* @return void
*/
public function redirect($url, $status = NULL, $exit = true) {
public function redirect($url, $status = null, $exit = true) {
$this->redirectUrl = $url;
}

Expand Down Expand Up @@ -433,11 +433,11 @@ public function testSerializeParamsWithEncoding() {
$this->assertEquals($this->_urlEncode('ef?'), $result['title']);
}

/**
* replace the base64encoded values that could harm the url (/ and =) with harmless characters
*
* @return string
*/
/**
* replace the base64encoded values that could harm the url (/ and =) with harmless characters
*
* @return string
*/
protected function _urlEncode($str) {
return str_replace(array('/', '='), array('-', '_'), base64_encode($str)); ////rtrim(strtr(base64_encode($str), '+/', '-_'), '=');
}
Expand Down
17 changes: 8 additions & 9 deletions Test/Case/Model/Behavior/SearchableBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,15 +379,15 @@ public function testLikeCondition() {
$this->assertEquals($expected, $result);

// cross model searches + named keys (shorthand)
$this->Article->bindModel(array('belongsTo' =>array('User')));
$this->Article->bindModel(array('belongsTo' => array('User')));
$this->Article->filterArgs = array(
'faketitle' => array('type' => 'like', 'field' => array('title', 'User.name'), 'before' => false, 'after' => true)
);
$this->Article->Behaviors->detach('Searchable');
$this->Article->Behaviors->attach('Search.Searchable');
$data = array('faketitle' => 'First');
$result = $this->Article->parseCriteria($data);
$expected = array('OR' =>array('Article.title LIKE' => 'First%', 'User.name LIKE' => 'First%'));
$expected = array('OR' => array('Article.title LIKE' => 'First%', 'User.name LIKE' => 'First%'));
$this->assertEquals($expected, $result);

// with already existing or conditions + named keys (shorthand)
Expand All @@ -401,18 +401,18 @@ public function testLikeCondition() {
$data = array('faketitle' => 'First', 'otherfaketitle' => 'Second');
$result = $this->Article->parseCriteria($data);
$expected = array(
'OR' =>array('Article.title LIKE' => 'First%', 'User.name LIKE' => 'First%'),
array('OR' =>array('Article.descr LIKE' => 'Second%', 'Article.comment LIKE' => 'Second%'))
'OR' => array('Article.title LIKE' => 'First%', 'User.name LIKE' => 'First%'),
array('OR' => array('Article.descr LIKE' => 'Second%', 'Article.comment LIKE' => 'Second%'))
);
$this->assertEquals($expected, $result);

// wildcards and and/or connectors
$this->Article->filterArgs = array(
array('name' => 'faketitle', 'type' => 'like', 'field' => 'Article.title', 'connectorAnd' => '+', 'connectorOr' => ',', 'before' => true, 'after' =>true)
array('name' => 'faketitle', 'type' => 'like', 'field' => 'Article.title', 'connectorAnd' => '+', 'connectorOr' => ',', 'before' => true, 'after' => true)
);
$data = array('faketitle' => 'First%+Second%, Third%');
$result = $this->Article->parseCriteria($data);
$expected = array(0 => array('OR' =>array(
$expected = array(0 => array('OR' => array(
array('AND' => array(
array('Article.title LIKE' => '%First\%%'),
array('Article.title LIKE' => '%Second\%%'),
Expand All @@ -422,7 +422,6 @@ public function testLikeCondition() {
)),
)));
$this->assertEquals($expected, $result);

}

/**
Expand All @@ -446,7 +445,7 @@ public function testSubQueryCondition() {

$data = array('tags' => 'Cake');
$result = $this->Article->parseCriteria($data);
$expected = array(array('Article.id in (SELECT `Tagged`.`foreign_key` FROM `'.$database.'`.`'.$this->Article->tablePrefix.'tagged` AS `Tagged` LEFT JOIN `'.$database.'`.`'.$this->Article->tablePrefix.'tags` AS `Tag` ON (`Tagged`.`tag_id` = `Tag`.`id`) WHERE `Tag`.`name` = \'Cake\')'));
$expected = array(array('Article.id in (SELECT `Tagged`.`foreign_key` FROM `' . $database . '`.`' . $this->Article->tablePrefix . 'tagged` AS `Tagged` LEFT JOIN `' . $database . '`.`' . $this->Article->tablePrefix . 'tags` AS `Tag` ON (`Tagged`.`tag_id` = `Tag`.`id`) WHERE `Tag`.`name` = \'Cake\')'));
$this->assertEquals($expected, $result);
}

Expand All @@ -468,7 +467,7 @@ public function testSubQueryEmptyCondition() {
$data = array('tags' => 'Cake');
$result = $this->Article->parseCriteria($data);

$expected = array(array('Article.id in (SELECT `Tagged`.`foreign_key` FROM `'.$database.'`.`'.$this->Article->tablePrefix.'tagged` AS `Tagged` LEFT JOIN `'.$database.'`.`'.$this->Article->tablePrefix.'tags` AS `Tag` ON (`Tagged`.`tag_id` = `Tag`.`id`) WHERE `Tag`.`name` = \'Cake\')'));
$expected = array(array('Article.id in (SELECT `Tagged`.`foreign_key` FROM `' . $database . '`.`' . $this->Article->tablePrefix . 'tagged` AS `Tagged` LEFT JOIN `' . $database . '`.`' . $this->Article->tablePrefix . 'tags` AS `Tag` ON (`Tagged`.`tag_id` = `Tag`.`id`) WHERE `Tag`.`name` = \'Cake\')'));

$this->assertEquals($expected, $result);
}
Expand Down
8 changes: 5 additions & 3 deletions Test/Fixture/ArticleFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
class ArticleFixture extends CakeTestFixture {


/**
* fields property
*
Expand All @@ -31,7 +30,8 @@ class ArticleFixture extends CakeTestFixture {
'views' => array('type' => 'integer', 'null' => false),
'comments' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 10),
'created' => 'datetime',
'updated' => 'datetime');
'updated' => 'datetime',
);

/**
* records property
Expand All @@ -41,5 +41,7 @@ class ArticleFixture extends CakeTestFixture {
public $records = array(
array('id' => 1, 'title' => 'First Article', 'body' => 'First Article', 'slug' => 'first_article', 'views' => 2, 'comments' => 1, 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'),
array('id' => 2, 'title' => 'Second Article', 'body' => 'Second Article', 'slug' => 'second_article', 'views' => 1, 'comments' => 2, 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31'),
array('id' => 3, 'title' => 'Third Article', 'body' => 'Third Article', 'slug' => 'third_article', 'views' => 2, 'comments' => 3, 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'));
array('id' => 3, 'title' => 'Third Article', 'body' => 'Third Article', 'slug' => 'third_article', 'views' => 2, 'comments' => 3, 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'),
);

}
9 changes: 6 additions & 3 deletions Test/Fixture/PostFixture.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright 2009-2010, Cake Development Corporation (http://cakedc.com)
*
Expand All @@ -17,7 +18,6 @@
*/
class PostFixture extends CakeTestFixture {


/**
* fields property
*
Expand All @@ -30,7 +30,8 @@ class PostFixture extends CakeTestFixture {
'views' => array('type' => 'integer', 'null' => false),
'comments' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 10),
'created' => 'datetime',
'updated' => 'datetime');
'updated' => 'datetime',
);

/**
* records property
Expand All @@ -40,5 +41,7 @@ class PostFixture extends CakeTestFixture {
public $records = array(
array('id' => 1, 'title' => 'First Post', 'slug' => 'first_post', 'views' => 2, 'comments' => 1, 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'),
array('id' => 2, 'title' => 'Second Post', 'slug' => 'second_post', 'views' => 1, 'comments' => 2, 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31'),
array('id' => 3, 'title' => 'Third Post', 'slug' => 'third_post', 'views' => 2, 'comments' => 3, 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'));
array('id' => 3, 'title' => 'Third Post', 'slug' => 'third_post', 'views' => 2, 'comments' => 3, 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'),
);

}
18 changes: 10 additions & 8 deletions Test/Fixture/TagFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
class TagFixture extends CakeTestFixture {


/**
* Table
*
Expand All @@ -31,13 +30,13 @@ class TagFixture extends CakeTestFixture {
* @var array $fields
*/
public $fields = array(
'id' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 36, 'key' => 'primary'),
'identifier' => array('type' => 'string', 'null' => true, 'default' => NULL, 'length' => 30, 'key' => 'index'),
'name' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 30),
'keyname' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 30),
'id' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 36, 'key' => 'primary'),
'identifier' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 30, 'key' => 'index'),
'name' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 30),
'keyname' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 30),
'weight' => array('type' => 'integer', 'null' => false, 'default' => 0, 'length' => 2),
'created' => array('type' => 'datetime', 'null' => true, 'default' => NULL),
'modified' => array('type' => 'datetime', 'null' => true, 'default' => NULL),
'created' => array('type' => 'datetime', 'null' => true, 'default' => null),
'modified' => array('type' => 'datetime', 'null' => true, 'default' => null),
'indexes' => array(
'PRIMARY' => array('column' => 'id', 'unique' => 1),
'UNIQUE_TAG' => array('column' => array('identifier', 'keyname'), 'unique' => 1)
Expand Down Expand Up @@ -73,5 +72,8 @@ class TagFixture extends CakeTestFixture {
'keyname' => 'cakedc',
'weight' => 2,
'created' => '2008-06-01 18:18:15',
'modified' => '2008-06-01 18:18:15'));
'modified' => '2008-06-01 18:18:15',
)
);

}
16 changes: 8 additions & 8 deletions Test/Fixture/TaggedFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
class TaggedFixture extends CakeTestFixture {


/**
* Table
*
Expand All @@ -31,13 +30,13 @@ class TaggedFixture extends CakeTestFixture {
* @var array $fields
*/
public $fields = array(
'id' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 36, 'key' => 'primary'),
'foreign_key' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 36),
'tag_id' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 36),
'model' => array('type' => 'string', 'null' => false, 'default' => NULL, 'key' => 'index'),
'language' => array('type' => 'string', 'null' => true, 'default' => NULL, 'length' => 6),
'created' => array('type' => 'datetime', 'null' => true, 'default' => NULL),
'modified' => array('type' => 'datetime', 'null' => true, 'default' => NULL),
'id' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 36, 'key' => 'primary'),
'foreign_key' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 36),
'tag_id' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 36),
'model' => array('type' => 'string', 'null' => false, 'default' => null, 'key' => 'index'),
'language' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 6),
'created' => array('type' => 'datetime', 'null' => true, 'default' => null),
'modified' => array('type' => 'datetime', 'null' => true, 'default' => null),
'indexes' => array(
'PRIMARY' => array('column' => 'id', 'unique' => 1),
'UNIQUE_TAGGING' => array('column' => array('model', 'foreign_key', 'tag_id', 'language'), 'unique' => 1),
Expand Down Expand Up @@ -80,4 +79,5 @@ class TaggedFixture extends CakeTestFixture {
'modified' => '2008-12-02 12:32:31',
),
);

}

0 comments on commit 0bf6246

Please sign in to comment.