Skip to content

Commit

Permalink
Version 5.3.0 (#18)
Browse files Browse the repository at this point in the history
* Access methods for overriding all filter values

* version bump
  • Loading branch information
janhartigan authored Oct 25, 2017
1 parent 7bbc579 commit 1fbe150
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This library provides a set of classes that help represent requests for complex data and provides a way to convert requests to and from a standard JSON format. If you have interfaces with tons of parameters ($filters, $groupings, $page, $rowsPerPage, etc.), or if you're just looking for a standard way to communicate complex requests to other apps without racking your brain over how to represent this data in JSON, you will like this library.

- **Version:** 5.2.0
- **Version:** 5.3.0

[![Build Status](https://travis-ci.org/mongerinc/search-request.png?branch=master)](https://travis-ci.org/mongerinc/search-request)

Expand Down
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Changelog

### 5.3.0
- Allow overriding of all filter values

### 5.2.1
- Fixing deep-cloning duplicating sorts/facets/groups

Expand Down
42 changes: 42 additions & 0 deletions src/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,48 @@ public function setField($field)
return $this;
}

/**
* Sets the operator
*
* @param string $operator
*
* @return $this
*/
public function setOperator($operator)
{
$this->operator = $operator;

return $this;
}

/**
* Sets the value
*
* @param string $value
*
* @return $this
*/
public function setValue($value)
{
$this->value = $value;

return $this;
}

/**
* Sets the boolean
*
* @param string $boolean
*
* @return $this
*/
public function setBoolean($boolean)
{
$this->boolean = $boolean;

return $this;
}

/**
* Converts the filter to a representative array
*
Expand Down
16 changes: 16 additions & 0 deletions tests/Filter/FilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,22 @@ public function removeExisting()
]));
}

/**
* @test
*/
public function overrideValues()
{
$request = new SearchRequest;

$request->where('foo', '>', 5, 'and');

$request->getFilter('foo')->setOperator('<')->setValue(10)->setBoolean('or');

$this->checkRequest($request, $this->buildExpectedFilterSet([
['field' => 'foo', 'operator' => '<', 'value' => 10, 'boolean' => 'or'],
]));
}

/**
* Checks the filter set for the provided request against the given expected filter set
*
Expand Down

0 comments on commit 1fbe150

Please sign in to comment.