Skip to content

Commit

Permalink
Cover default integer list filter
Browse files Browse the repository at this point in the history
  • Loading branch information
alterphp committed Jan 29, 2019
1 parent 59869d0 commit 665e22e
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/Controller/ListFormFiltersTest.php
Expand Up @@ -133,4 +133,19 @@ public function testListFilterCombinedOperator()
$crawler->filter('section.content-footer .list-pagination-counter')->text()
);
}

public function testListFilterDefaultInteger()
{
$crawler = $this->requestListView(
'Product',
[],
['stock' => ['value' => 30]]
);

$this->assertSame(200, $this->client->getResponse()->getStatusCode());
$this->assertContains(
'25 results',
$crawler->filter('section.content-footer .list-pagination-counter')->text()
);
}
}
1 change: 1 addition & 0 deletions tests/Fixtures/App/config/config_list_form_filters.yaml
Expand Up @@ -22,6 +22,7 @@ easy_admin:
- { property: replenishmentType, type_options: { choices_static_callback: [getReplenishmentTypeValues, [true]] } }
- enabled
- category
- stock
- { name: priceGreaterThan, property: price, operator: gt }
- { name: priceGreaterThanOrEquals, property: price, operator: gte }
- { name: priceLowerThan, property: price, operator: lt }
Expand Down
1 change: 1 addition & 0 deletions tests/Fixtures/AppTestBundle/DataFixtures/AppFixtures.php
Expand Up @@ -169,6 +169,7 @@ private function createProducts(): array
$product->setName($this->getRandomName());
$product->setReplenishmentType($this->getReplenishmentType());
$product->setPrice($i * 100);
$product->setStock(($i % 4) * 10);
$product->setTags($this->getRandomTags());
$product->setEan($this->getRandomEan());
$product->setCategory($category);
Expand Down
28 changes: 28 additions & 0 deletions tests/Fixtures/AppTestBundle/Entity/FunctionalTests/Product.php
Expand Up @@ -103,6 +103,14 @@ class Product
*/
protected $price = 0.0;

/**
* The stock of the product.
*
* @var int
* @ORM\Column(type="integer")
*/
protected $stock = 0;

/**
* The reference of the product.
*
Expand Down Expand Up @@ -426,6 +434,26 @@ public function getPrice()
return $this->price;
}

/**
* Set the stock.
*
* @param int $stock
*/
public function setStock($stock)
{
$this->stock = $stock;
}

/**
* Get the stock of the product.
*
* @return int
*/
public function getStock()
{
return $this->stock;
}

/**
* Set the list of the tags.
*
Expand Down

0 comments on commit 665e22e

Please sign in to comment.