|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Tests; |
|
4
|
|
|
|
|
5
|
|
|
use GeminiLabs\SiteReviews\Defaults\ReviewsDefaults; |
|
6
|
|
|
use GeminiLabs\SiteReviews\Defaults\SiteReviewsDefaults; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Test case for the Plugin. |
|
10
|
|
|
* @group plugin |
|
11
|
|
|
*/ |
|
12
|
|
|
class DefaultsTest extends \WP_UnitTestCase |
|
|
|
|
|
|
13
|
|
|
{ |
|
14
|
|
|
public function test_reviews_restrict() |
|
15
|
|
|
{ |
|
16
|
|
|
$postId = self::factory()->post->create(); |
|
17
|
|
|
$termId = self::factory()->term->create(['taxonomy' => glsr()->taxonomy]); |
|
18
|
|
|
$userId = self::factory()->user->create(); |
|
19
|
|
|
$args = [ |
|
20
|
|
|
'assigned_to' => $postId, |
|
21
|
|
|
'block' => '', |
|
22
|
|
|
'category' => $termId, |
|
23
|
|
|
'class' => '', |
|
24
|
|
|
'display' => 1, |
|
25
|
|
|
'hide' => [], |
|
26
|
|
|
'id' => '', |
|
27
|
|
|
'offset' => '', |
|
28
|
|
|
'page' => 2, |
|
29
|
|
|
'pageUrl' => 'http://site-reviews.test/reviews/', |
|
30
|
|
|
'pagination' => 'ajax', |
|
31
|
|
|
'schema' => '', |
|
32
|
|
|
'terms' => '', |
|
33
|
|
|
'type' => 'local', |
|
34
|
|
|
'user' => $userId, |
|
35
|
|
|
]; |
|
36
|
|
|
$expected = [ |
|
37
|
|
|
'assigned_posts' => [$postId], |
|
38
|
|
|
'assigned_posts_types' => [], |
|
39
|
|
|
'assigned_terms' => [$termId], |
|
40
|
|
|
'assigned_users' => [$userId], |
|
41
|
|
|
'content' => '', |
|
42
|
|
|
'date' => [ |
|
43
|
|
|
'after' => '', |
|
44
|
|
|
'before' => '', |
|
45
|
|
|
'day' => '', |
|
46
|
|
|
'inclusive' => '', |
|
47
|
|
|
'month' => '', |
|
48
|
|
|
'year' => '', |
|
49
|
|
|
], |
|
50
|
|
|
'email' => '', |
|
51
|
|
|
'integration' => '', |
|
52
|
|
|
'ip_address' => '', |
|
53
|
|
|
'offset' => 0, |
|
54
|
|
|
'order' => 'DESC', |
|
55
|
|
|
'orderby' => 'p.post_date', |
|
56
|
|
|
'page' => 2, |
|
57
|
|
|
'per_page' => 1, |
|
58
|
|
|
'post__in' => [], |
|
59
|
|
|
'post__not_in' => [], |
|
60
|
|
|
'rating' => 0, |
|
61
|
|
|
'rating_field' => 'rating', |
|
62
|
|
|
'status' => 1, |
|
63
|
|
|
'terms' => -1, |
|
64
|
|
|
'type' => 'local', |
|
65
|
|
|
'user__in' => [], |
|
66
|
|
|
'user__not_in' => [], |
|
67
|
|
|
]; |
|
68
|
|
|
$test = glsr()->args(glsr(ReviewsDefaults::class)->restrict($args)); |
|
69
|
|
|
$this->assertEquals(count($test), count(glsr(ReviewsDefaults::class)->defaults())); |
|
70
|
|
|
$this->assertEquals($test->toArray(), $expected); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function test_site_reviews_restrict() |
|
74
|
|
|
{ |
|
75
|
|
|
$postId = self::factory()->post->create(); |
|
76
|
|
|
$termId = self::factory()->term->create(['taxonomy' => glsr()->taxonomy]); |
|
77
|
|
|
$userId = self::factory()->user->create(); |
|
78
|
|
|
$args = [ |
|
79
|
|
|
'assigned_to' => $postId, |
|
80
|
|
|
'category' => $termId, |
|
81
|
|
|
'class' => '', |
|
82
|
|
|
'className' => '', |
|
83
|
|
|
'display' => 1, |
|
84
|
|
|
'hide' => '', |
|
85
|
|
|
'id' => '', |
|
86
|
|
|
'pagination' => 'ajax', |
|
87
|
|
|
'post_id' => 4466, |
|
88
|
|
|
'rating' => 3, |
|
89
|
|
|
'schema' => 1, |
|
90
|
|
|
'terms' => '', |
|
91
|
|
|
'type' => 'local', |
|
92
|
|
|
'user' => $userId, |
|
93
|
|
|
]; |
|
94
|
|
|
$test = glsr(SiteReviewsDefaults::class)->restrict($args); |
|
95
|
|
|
$this->assertEquals(count($test), count(glsr(SiteReviewsDefaults::class)->defaults())); |
|
96
|
|
|
$this->assertTrue(str_starts_with($test['id'], glsr()->prefix)); |
|
97
|
|
|
unset($test['id']); |
|
98
|
|
|
$this->assertEquals($test, [ |
|
99
|
|
|
'assigned_posts' => $postId, |
|
100
|
|
|
'assigned_terms' => $termId, |
|
101
|
|
|
'assigned_users' => $userId, |
|
102
|
|
|
'author' => 0, |
|
103
|
|
|
'class' => '', |
|
104
|
|
|
'debug' => false, |
|
105
|
|
|
'display' => 1, |
|
106
|
|
|
'hide' => [], |
|
107
|
|
|
'offset' => 0, |
|
108
|
|
|
'page' => 1, |
|
109
|
|
|
'pagination' => 'ajax', |
|
110
|
|
|
'rating' => 3, |
|
111
|
|
|
'rating_field' => 'rating', |
|
112
|
|
|
'schema' => true, |
|
113
|
|
|
'terms' => '', |
|
114
|
|
|
'type' => 'local', |
|
115
|
|
|
]); |
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths