|
7 | 7 | class TicketArticleTest extends AbstractBaseTest |
8 | 8 | { |
9 | 9 | protected $resource_type = ResourceType::TICKET_ARTICLE; |
10 | | - protected $update_field = 'body'; |
11 | 10 |
|
12 | 11 | public function objectCreateProvider() |
13 | 12 | { |
@@ -185,4 +184,55 @@ public function testCreate( $values, $expected_success ) |
185 | 184 | ); |
186 | 185 | } |
187 | 186 | } |
| 187 | + |
| 188 | + /** |
| 189 | + * @depends testCreate |
| 190 | + */ |
| 191 | + public function testUpdate() |
| 192 | + { |
| 193 | + foreach ( self::$created_objects as $created_object ) { |
| 194 | + $created_object_id = $created_object->getID(); |
| 195 | + if ( empty( $created_object_id ) ) { |
| 196 | + continue; |
| 197 | + } |
| 198 | + |
| 199 | + // Change a value. |
| 200 | + $is_internal = $created_object->getValue('internal') ? true : false; |
| 201 | + $new_is_internal = !$is_internal; |
| 202 | + |
| 203 | + $created_object->setValue( 'internal', $new_is_internal ); |
| 204 | + $saved_object = $created_object->save(); |
| 205 | + |
| 206 | + $this->assertFalse( |
| 207 | + $created_object->hasError(), |
| 208 | + 'Error must not be set after update of object.' |
| 209 | + ); |
| 210 | + |
| 211 | + $this->assertInstanceOf( |
| 212 | + $this->resource_type, |
| 213 | + $saved_object |
| 214 | + ); |
| 215 | + |
| 216 | + $this->assertSame( |
| 217 | + $created_object, |
| 218 | + $saved_object, |
| 219 | + 'Saving an object must return the same object again.' |
| 220 | + ); |
| 221 | + |
| 222 | + // Compare changed value. |
| 223 | + $this->assertEquals( |
| 224 | + $new_is_internal, |
| 225 | + $created_object->getValue('internal') ? true : false, |
| 226 | + 'Changed value of object must match expected one.' |
| 227 | + ); |
| 228 | + |
| 229 | + // Fetch object data with a fresh object to check again if value has been changed. |
| 230 | + $fetched_object = self::getClient()->resource( $this->resource_type )->get($created_object_id); |
| 231 | + $this->assertEquals( |
| 232 | + $new_is_internal, |
| 233 | + $fetched_object->getValue('internal') ? true : false, |
| 234 | + 'Value of fetched object must match expected one.' |
| 235 | + ); |
| 236 | + } |
| 237 | + } |
188 | 238 | } |
0 commit comments