Skip to content

Commit cdd637c

Browse files
committed
Fix Utils::isRepeaterTemplate function.
1 parent 748feee commit cdd637c

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/Utils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public static function normalizeTypeName($name)
216216
public static function isRepeaterTemplate(Template $template)
217217
{
218218
// if it's not prefixed with "repeater_" then it's not a repeater template
219-
if (strpos($template->name, 'repeater_' !== 0)) {
219+
if (strpos($template->name, 'repeater_') !== 0) {
220220
return false;
221221
}
222222

test/UtilsTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace ProcessWire\GraphQL\Test;
4+
5+
use ProcessWire\Template;
6+
use ProcessWire\GraphQL\Test\GraphqlTestCase;
7+
use ProcessWire\GraphQL\Utils;
8+
9+
class UtilsTest extends GraphQLTestCase
10+
{
11+
public static function testIsRepeaterTemplate()
12+
{
13+
$repeaterTemplate = new Template();
14+
$repeaterTemplate->name = 'something';
15+
assertFalse(Utils::isRepeaterTemplate($repeaterTemplate), 'Incorrectly marks template as a repeater.');
16+
$repeaterTemplate->name = 'repeater_something';
17+
assertFalse(Utils::isRepeaterTemplate($repeaterTemplate), 'Incorrectly marks template as a repeater.');
18+
$repeaterTemplate->flags = $repeaterTemplate->flags | Template::flagSystem;
19+
assertTrue(Utils::isRepeaterTemplate($repeaterTemplate), 'Does not properly detect a repeater template.');
20+
}
21+
}

0 commit comments

Comments
 (0)