@@ -17,14 +17,67 @@ public function setUp()
17
17
$ this ->model = $ objectManager ->getObject ('Magento\Framework\Data\Collection\Filesystem ' );
18
18
}
19
19
20
- public function testFilterCallbackLike ()
20
+ /**
21
+ * @param $field
22
+ * @param $filterValue
23
+ * @param $row
24
+ * @param $expected
25
+ *
26
+ * @dataProvider testFilterCallbackLikeDataProvider
27
+ */
28
+ public function testFilterCallbackLike ($ field , $ filterValue , $ row , $ expected )
21
29
{
22
- $ field = 'field ' ;
23
- $ row = [$ field => 'beginning_filter_target_end ' ,];
24
- $ filterValueSuccess = new \Zend_Db_Expr ('%filter_target% ' );
25
- $ filterValueFailure = new \Zend_Db_Expr ('%not_found_in_the_row% ' );
30
+ $ filterValue = new \Zend_Db_Expr ($ filterValue );
26
31
27
- $ this ->assertTrue ($ this ->model ->filterCallbackLike ($ field , $ filterValueSuccess , $ row ));
28
- $ this ->assertFalse ($ this ->model ->filterCallbackLike ($ field , $ filterValueFailure , $ row ));
32
+ $ this ->assertEquals ($ expected , $ this ->model ->filterCallbackLike ($ field , $ filterValue , $ row ));
33
+ }
34
+
35
+ /**
36
+ * @return array
37
+ */
38
+ public function testFilterCallbackLikeDataProvider ()
39
+ {
40
+ $ field = 'field ' ;
41
+ $ testValue = '\'\'\'test \'\'\'Filter \'\'\'Value \'\'\'' ;
42
+ return [
43
+ [$ field , '\'%test% \'' , [$ field => $ testValue ,], true ],
44
+ [$ field , '% \'test% ' , [$ field => $ testValue ,], true ],
45
+ [$ field , '% \'test \'% ' , [$ field => $ testValue ,], true ],
46
+ [$ field , '% \'\'test% ' , [$ field => $ testValue ,], true ],
47
+ [$ field , '% \'\'test \'\'% ' , [$ field => $ testValue ,], true ],
48
+ [$ field , '% \'\'\'test% ' , [$ field => $ testValue ,], true ],
49
+ [$ field , '% \'\'\'test \'\'\'% ' , [$ field => $ testValue ,], true ],
50
+ [$ field , '% \'\'\'\'test% ' , [$ field => $ testValue ,], false ],
51
+
52
+ [$ field , '\'%Value% \'' , [$ field => $ testValue ,], true ],
53
+ [$ field , '%Value \'% ' , [$ field => $ testValue ,], true ],
54
+ [$ field , '% \'Value \'% ' , [$ field => $ testValue ,], true ],
55
+ [$ field , '%Value \'\'% ' , [$ field => $ testValue ,], true ],
56
+ [$ field , '% \'\'Value \'\'% ' , [$ field => $ testValue ,], true ],
57
+ [$ field , '%Value \'\'\'% ' , [$ field => $ testValue ,], true ],
58
+ [$ field , '% \'\'\'Value \'\'\'% ' , [$ field => $ testValue ,], true ],
59
+ [$ field , '%Value% \'\'\'\'% ' , [$ field => $ testValue ,], false ],
60
+
61
+ [$ field , '\'% \'\'\'test \'\'\'Filter \'\'\'Value \'\'\'% \'' , [$ field => $ testValue ,], true ],
62
+ [$ field , '\'\'\'% \'\'\'test \'\'\'Filter \'\'\'Value \'\'\'% \'\'\'' , [$ field => $ testValue ,], true ],
63
+ [$ field , '%test \'\'\'Filter \'\'\'Value% ' , [$ field => $ testValue ,], true ],
64
+ [$ field , '%test \'\'\'Filter \'\'\'Value \'\'\'% ' , [$ field => $ testValue ,], true ],
65
+ [$ field , '% \'\'\'test \'\'\'Filter \'\'\'Value% ' , [$ field => $ testValue ,], true ],
66
+ [$ field , '% \'\'\'Filter \'\'\'Value \'\'\'% ' , [$ field => $ testValue ,], true ],
67
+ [$ field , '%Filter \'\'\'Value \'\'\'% ' , [$ field => $ testValue ,], true ],
68
+ [$ field , '% \'\'\'Filter \'\'\'Value% ' , [$ field => $ testValue ,], true ],
69
+ [$ field , '%Filter \'\'\'Value% ' , [$ field => $ testValue ,], true ],
70
+ [$ field , '%Filter \'\'\'\'Value% ' , [$ field => $ testValue ,], false ],
71
+
72
+ [$ field , '\'% \'\'\'Filter \'\'\'% \'' , [$ field => $ testValue ,], true ],
73
+ [$ field , '%Filter \'\'\'% ' , [$ field => $ testValue ,], true ],
74
+ [$ field , '% \'\'\'Filter% ' , [$ field => $ testValue ,], true ],
75
+ [$ field , '% \'Filter% ' , [$ field => $ testValue ,], true ],
76
+ [$ field , '%Filter \'% ' , [$ field => $ testValue ,], true ],
77
+ [$ field , '%Filter% ' , [$ field => $ testValue ,], true ],
78
+ [$ field , '%Filter \'\'\'\'% ' , [$ field => $ testValue ,], false ],
79
+
80
+ [$ field , '\'%no_match_value% \'' , [$ field => $ testValue ,], false ],
81
+ ];
29
82
}
30
83
}
0 commit comments