Skip to content

Commit 2a18e4b

Browse files
committed
Add case three to FieldtypeOptions test.
1 parent 3f7558d commit 2a18e4b

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
/**
4+
* You can pass a plain string for options field that
5+
* stores single option
6+
*/
7+
8+
namespace ProcessWire\GraphQL\Test\Field\Page\Fieldtype\FieldtypeOptions;
9+
10+
use \ProcessWire\GraphQL\Utils;
11+
use \ProcessWire\GraphQL\Test\GraphQLTestCase;
12+
use \ProcessWire\GraphQL\Test\Field\Page\Traits\AccessTrait;
13+
use ProcessWire\NullPage;
14+
15+
class FieldtypeOptionsCaseThreeTest extends GraphQLTestCase {
16+
17+
const accessRules = [
18+
'legalTemplates' => ['cities', 'city'],
19+
'legalFields' => ['options_single', 'title'],
20+
];
21+
22+
use AccessTrait;
23+
24+
public function testValue()
25+
{
26+
$name = "new-city";
27+
$title = "New City";
28+
$option = 'Mon';
29+
$query = 'mutation createPage ($page: CityCreateInputType!) {
30+
createCity (page: $page) {
31+
name
32+
id
33+
title
34+
options_single {
35+
title
36+
value
37+
id
38+
}
39+
}
40+
}';
41+
$variables = [
42+
"page" => [
43+
"parent" => "4049",
44+
"name" => $name,
45+
"title" => $title,
46+
"options_single" => $option,
47+
]
48+
];
49+
$res = $this->execute($query, json_encode($variables));
50+
51+
$newCity = Utils::pages()->get("template=city, name=$name");
52+
$this->assertTrue(!$newCity instanceof NullPage, 'New Page is created.');
53+
$this->assertEquals($name, $newCity->name, 'New Page has correct name.');
54+
$this->assertEquals($title, $newCity->title, 'New Page has correct title.');
55+
$this->assertEquals($option, $newCity->options_single->value, 'New Page has correct option value.');
56+
}
57+
58+
}

0 commit comments

Comments
 (0)