From 28f0fc730690b6e2980baa35bd713c7740301d8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Po=C5=82a=C4=87?= Date: Wed, 11 May 2016 22:25:39 +0200 Subject: [PATCH] Add tests for unique_by working with string as parameter --- Tests/Fixtures/filters/unique_by_eq.test | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Tests/Fixtures/filters/unique_by_eq.test diff --git a/Tests/Fixtures/filters/unique_by_eq.test b/Tests/Fixtures/filters/unique_by_eq.test new file mode 100644 index 0000000..4b0c02a --- /dev/null +++ b/Tests/Fixtures/filters/unique_by_eq.test @@ -0,0 +1,29 @@ +--TEST-- +"unique_by" works with '==' and '===' as parameter +--TEMPLATE-- +{% for i in list|unique_by('==') %} + * {{ i.data }} +{% endfor %} +=== +{% for i in list|unique_by('===') %} + * {{ i.data }} +{% endfor %} +--DATA-- +$obj1 = new \StdClass; +$obj1->data = "a"; +$obj2 = new \StdClass; +$obj2->data = "a"; +$obj3 = new \StdClass; +$obj3->data = "b"; +$obj4 = new \StdClass; +$obj4->data = "c"; +return [ 'list' => [$obj1, $obj4, $obj2, $obj3, $obj1, $obj3] ]; +--EXPECT-- + * a + * c + * b +=== + * a + * c + * a + * b \ No newline at end of file