ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilTermsOfServiceCriterionConfigTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
9 {
13  public function testConfigCanBePassedAsArray()
14  {
15  $actualKey = 'phpunit';
16  $actualValue = 'rulz';
17 
18  $data = [$actualKey => $actualValue];
19 
20  $config = new \ilTermsOfServiceCriterionConfig($data);
21 
22  $expected = json_encode($data);
23 
24  $this->assertEquals($expected, $config->toJson());
25  $this->assertArrayHasKey($actualKey, $config);
26  $this->assertEquals($actualValue, $config[$actualKey]);
27  }
28 
32  public function testConfigCanBePassedAsJson()
33  {
34  $actualKey = 'phpunit';
35  $actualValue = 'rulz';
36 
37  $data = json_encode([$actualKey => $actualValue]);
38 
39  $config = new \ilTermsOfServiceCriterionConfig($data);
40 
41  $this->assertEquals($data, $config->toJson());
42  $this->assertArrayHasKey($actualKey, $config);
43  $this->assertEquals($actualValue, $config[$actualKey]);
44  }
45 
50  {
51  $actualKey = 'phpunit';
52  $actualValue = 'rulz';
53 
54  $data = json_encode([$actualKey => $actualValue]);
55 
56  $config = new \ilTermsOfServiceCriterionConfig();
57  $config->fromJson($data);
58 
59  $this->assertEquals($data, $config->toJson());
60  $this->assertArrayHasKey($actualKey, $config);
61  $this->assertEquals($actualValue, $config[$actualKey]);
62  }
63 }
$config
Definition: bootstrap.php:15
Class ilTermsOfServiceCriterionBaseTest.
Class ilTermsOfServiceCriterionConfigTest.
$data
Definition: bench.php:6