Permalink
Browse files

Removed unused test and simplified validateSort

  • Loading branch information...
1 parent aec9564 commit fb68446713294db1e09e91330927b39ecdbb3472 @Grafikart Grafikart committed Jan 29, 2014
@@ -305,28 +305,26 @@ public function validateSort(Table $object, array $options) {
return $options;
}
- if (is_array($options['order'])) {
- $tableAlias = $object->alias();
- $order = [];
+ $tableAlias = $object->alias();
+ $order = [];
- foreach ($options['order'] as $key => $value) {
- $field = $key;
- $alias = $tableAlias;
- if (is_numeric($key)){
- $order[] = $value;
- }else{
- if (strpos($key, '.') !== false) {
- list($alias, $field) = explode('.', $key);
- }
- $correctAlias = ($tableAlias == $alias);
+ foreach ($options['order'] as $key => $value) {
+ $field = $key;
+ $alias = $tableAlias;
+ if (is_numeric($key)){
+ $order[] = $value;
+ }else{
+ if (strpos($key, '.') !== false) {
+ list($alias, $field) = explode('.', $key);
+ }
+ $correctAlias = ($tableAlias == $alias);
- if ($correctAlias && $object->hasField($field)) {
- $order[$tableAlias . '.' . $field] = $value;
- }
+ if ($correctAlias && $object->hasField($field)) {
+ $order[$tableAlias . '.' . $field] = $value;
}
}
- $options['order'] = $order;
}
+ $options['order'] = $order;
return $options;
}
@@ -509,27 +509,6 @@ public function testValidateSortWithString() {
}
/**
- * test that numeric array order are used by paginator
- *
- * @return void
- */
- public function testValidateSortWithNumericArray() {
- $model = $this->getMock('Cake\ORM\Table');
- $model->expects($this->any())
- ->method('alias')
- ->will($this->returnValue('model'));
- $model->expects($this->any())->method('hasField')->will($this->returnValue(true));
-
- $options = array(
- 'order' => array('model.author_id DESC')
- );
- $result = $this->Paginator->validateSort($model, $options);
- $expected = array('model.author_id DESC');
-
- $this->assertEquals($expected, $result['order']);
- }
-
-/**
* Test that no sort doesn't trigger an error.
*
* @return void

0 comments on commit fb68446

Please sign in to comment.