ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
PersistenceTrackingDataTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 
25 class PersistenceTrackingDataTest extends TestCase
26 {
27  protected function getData(
28  bool $persisted,
29  PersistenceTrackingData ...$sub_data
31  return new class ($persisted, $sub_data) extends PersistenceTrackingDataImplementation {
32  public function __construct(
33  protected bool $persisted,
34  protected array $sub_data
35  ) {
36  }
37 
38  public function isPersisted(): bool
39  {
40  return $this->persisted;
41  }
42 
43  protected function getSubData(): \Generator
44  {
45  yield from $this->sub_data;
46  }
47 
48  public function exposeMarkAsChanged(): void
49  {
50  $this->markAsChanged();
51  }
52  };
53  }
54 
55  public function testContainsChangesTrueIfNotPersisted(): void
56  {
57  $data = $this->getData(false);
58  $this->assertTrue($data->containsChanges());
59  }
60 
61  public function testContainsChangesFalse(): void
62  {
63  $data = $this->getData(true);
64  $this->assertFalse($data->containsChanges());
65  }
66 
67  public function testContainsChangesTrue(): void
68  {
69  $data = $this->getData(true);
70  $data->exposeMarkAsChanged();
71 
72  $this->assertTrue($data->containsChanges());
73  }
74 
76  {
77  $data = $this->getData(
78  true,
79  $this->getData(true),
80  $this->getData(true)
81  );
82  $data->exposeMarkAsChanged();
83 
84  $this->assertTrue($data->containsChanges());
85  }
86 
88  {
89  $data = $this->getData(
90  true,
91  $this->getData(true),
92  $this->getData(true)
93  );
94  $data->exposeMarkAsChanged();
95 
96  $this->assertTrue($data->containsChanges());
97  }
98 
99  public function testContainsChangesTrueFromSubData(): void
100  {
101  $sub_data_1 = $this->getData(true);
102  $sub_data_2 = $this->getData(true);
103  $sub_data_1->exposeMarkAsChanged();
104  $data = $this->getData(true, $sub_data_1, $sub_data_2);
105 
106  $this->assertTrue($data->containsChanges());
107  }
108 }
getData(bool $persisted, PersistenceTrackingData ... $sub_data)
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:76