ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
PersistenceTrackingDataTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use PHPUnit\Framework\TestCase;
24
25class 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
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 @access public.
Definition: class.ilias.php:76
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...