~xibo-maintainers/xibo/tempel

« back to all changes in this revision

Viewing changes to tests/integration/DataSetTest.php

  • Committer: Dan Garner
  • Date: 2015-09-29 15:16:59 UTC
  • mto: (454.2.11) (471.2.2)
  • mto: This revision was merged to the branch mainline in revision 468.
  • Revision ID: git-v1:ae24387a7b1397750b6ec86d0f286373da05eb16
Fixed Display Version Information Form (not showing media name)

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 * (DataSetTest.php)
6
6
 */
7
7
 
8
 
namespace Xibo\Tests\Integration;
9
 
 
 
8
 
 
9
namespace integration;
 
10
 
 
11
 
 
12
use Xibo\Entity\DataSet;
 
13
use Xibo\Factory\DataSetFactory;
10
14
use Xibo\Helper\Random;
11
 
use Xibo\OAuth2\Client\Entity\XiboDataSet;
12
 
use Xibo\OAuth2\Client\Entity\XiboDataSetColumn;
13
 
use Xibo\OAuth2\Client\Entity\XiboDataSetRow;
14
15
use Xibo\Tests\LocalWebTestCase;
15
16
 
16
17
class DataSetTest extends LocalWebTestCase
17
18
{
18
 
    protected $startDataSets;
19
 
    
20
 
    /**
21
 
     * setUp - called before every test automatically
22
 
     */
23
 
    public function setup()
24
 
    {
25
 
        parent::setup();
26
 
        $this->startDataSets = (new XiboDataSet($this->getEntityProvider()))->get(['start' => 0, 'length' => 10000]);
27
 
    }
28
 
    
29
 
    /**
30
 
     * tearDown - called after every test automatically
31
 
     */
32
 
    public function tearDown()
33
 
    {
34
 
        // tearDown all datasets that weren't there initially
35
 
        $finalDataSets = (new XiboDataSet($this->getEntityProvider()))->get(['start' => 0, 'length' => 10000]);
36
 
 
37
 
        $difference = array_udiff($finalDataSets, $this->startDataSets, function ($a, $b) {
38
 
            /** @var XiboDataSet $a */
39
 
            /** @var XiboDataSet $b */
40
 
            return $a->dataSetId - $b->dataSetId;
41
 
        });
42
 
 
43
 
        # Loop over any remaining datasets and nuke them
44
 
        foreach ($difference as $dataSet) {
45
 
            /** @var XiboDataSet $dataSet */
46
 
            try {
47
 
                $dataSet->deleteWData();
48
 
            } catch (\Exception $e) {
49
 
                fwrite(STDERR, 'Unable to delete ' . $dataSet->dataSetId . '. E: ' . $e->getMessage() . PHP_EOL);
50
 
            }
51
 
        }
52
 
        parent::tearDown();
53
 
    }
54
 
 
55
 
    /*
56
 
    * List all datasets
57
 
    */
58
19
    public function testListAll()
59
20
    {
60
21
        $this->client->get('/dataset');
61
22
 
62
23
        $this->assertSame(200, $this->client->response->status());
63
24
        $this->assertNotEmpty($this->client->response->body());
 
25
 
64
26
        $object = json_decode($this->client->response->body());
 
27
 
65
28
        $this->assertObjectHasAttribute('data', $object, $this->client->response->body());
66
29
    }
67
30
 
71
34
     */
72
35
    public function testAdd()
73
36
    {
74
 
        # Generate random name
75
37
        $name = Random::generateString(8, 'phpunit');
76
 
        # Add dataset
 
38
 
77
39
        $response = $this->client->post('/dataset', [
78
40
            'dataSet' => $name,
79
41
            'description' => 'PHP Unit Test'
80
42
        ]);
81
 
        # Check if call was successful
 
43
 
82
44
        $this->assertSame(200, $this->client->response->status(), "Not successful: " . $response);
 
45
 
83
46
        $object = json_decode($this->client->response->body());
 
47
 
84
48
        $this->assertObjectHasAttribute('data', $object);
85
49
        $this->assertObjectHasAttribute('id', $object);
86
 
        # Check if dataset has the correct name
87
50
        $this->assertSame($name, $object->data->dataSet);
 
51
        return $object->id;
88
52
    }
89
53
 
90
 
 
91
54
    /**
92
55
     * Test edit
 
56
     * @param int $dataSetId
 
57
     * @return int the id
93
58
     * @depends testAdd
94
59
     */
95
 
    public function testEdit()
 
60
    public function testEdit($dataSetId)
96
61
    {
97
 
        # Create a new dataset
98
 
        $dataSet = (new XiboDataSet($this->getEntityProvider()))->create('phpunit dataset', 'phpunit description');
99
 
        # Generate new name and description
 
62
        $dataSet = DataSetFactory::getById($dataSetId);
 
63
 
100
64
        $name = Random::generateString(8, 'phpunit');
101
 
        $description = 'New description';
102
 
        # Edit the name and description
103
 
        $this->client->put('/dataset/' . $dataSet->dataSetId, [
 
65
 
 
66
        $this->client->put('/dataset/' . $dataSetId, [
104
67
            'dataSet' => $name,
105
 
            'description' => $description
 
68
            'description' => $dataSet->description
106
69
        ], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
107
 
        # Check if call was successful
 
70
 
108
71
        $this->assertSame(200, $this->client->response->status(), 'Not successful: ' . $this->client->response->body());
 
72
 
109
73
        $object = json_decode($this->client->response->body());
 
74
 
110
75
        $this->assertObjectHasAttribute('data', $object);
111
 
        # Check if name and description were correctly changed
112
 
        $this->assertSame($name, $object->data->dataSet);
113
 
        $this->assertSame($description, $object->data->description);
114
 
        # Deeper check by querying for dataset again
115
 
        $dataSetCheck = (new XiboDataSet($this->getEntityProvider()))->getById($object->id);
116
 
        $this->assertSame($name, $dataSetCheck->dataSet);
117
 
        $this->assertSame($description, $dataSetCheck->description);
118
 
        # Clean up the dataset as we no longer need it
119
 
        $dataSet->delete();
 
76
 
 
77
        // Deeper check by querying for resolution again
 
78
        $object = DataSetFactory::getById($dataSetId);
 
79
 
 
80
        $this->assertSame($name, $object->dataSet);
 
81
 
 
82
        return $dataSetId;
120
83
    }
121
84
 
122
85
    /**
 
86
     * @param $dataSetId
123
87
     * @depends testEdit
124
88
     */
125
 
    public function testDelete()
 
89
    public function testDelete($dataSetId)
126
90
    {
127
 
        # Generate new random names
128
 
        $name1 = Random::generateString(8, 'phpunit');
129
 
        $name2 = Random::generateString(8, 'phpunit');
130
 
        # Load in a couple of known dataSets
131
 
        $data1 = (new XiboDataSet($this->getEntityProvider()))->create($name1, 'phpunit description');
132
 
        $data2 = (new XiboDataSet($this->getEntityProvider()))->create($name2, 'phpunit description');
133
 
        # Delete the one we created last
134
 
        $this->client->delete('/dataset/' . $data2->dataSetId);
135
 
        # This should return 204 for success
136
 
        $response = json_decode($this->client->response->body());
137
 
        $this->assertSame(204, $response->status, $this->client->response->body());
138
 
        # Check only one remains
139
 
        $dataSets = (new XiboDataSet($this->getEntityProvider()))->get();
140
 
        $this->assertEquals(count($this->startDataSets) + 1, count($dataSets));
141
 
        $flag = false;
142
 
        foreach ($dataSets as $dataSet) {
143
 
            if ($dataSet->dataSetId == $data1->dataSetId) {
144
 
                $flag = true;
145
 
            }
146
 
        }
147
 
        $this->assertTrue($flag, 'dataSet ID ' . $data1->dataSetId . ' was not found after deleting a different dataset');
 
91
        $this->client->delete('/dataset/' . $dataSetId);
 
92
 
 
93
        $this->assertSame(200, $this->client->response->status(), $this->client->response->body());
148
94
    }
149
95
 
150
 
    # TO DO /dataset/import/
151
 
 
152
96
    /**
153
 
     * @dataProvider provideSuccessCases
 
97
     * Test adding a column
154
98
     */
155
 
    public function testAddColumnSuccess($columnName, $columnListContent, $columnOrd, $columnDataTypeId, $columnDataSetColumnTypeId, $columnFormula)
 
99
    public function testColumnAdd()
156
100
    {
157
 
        # Create radom name and description
 
101
        // Create a new dataset to use
 
102
        $dataSet = new DataSet();
 
103
        $dataSet->dataSet = Random::generateString(8, 'phpunit');
 
104
        $dataSet->description = 'PHP Unit column assign';
 
105
        $dataSet->userId = 1;
 
106
        $dataSet->save();
 
107
 
 
108
        // Generate a new for the new column
158
109
        $name = Random::generateString(8, 'phpunit');
159
 
        $description = 'PHP Unit column add';
160
 
        # Create new dataset
161
 
        $dataSet = (new XiboDataSet($this->getEntityProvider()))->create($name, $description);
162
 
        # Create new columns with arguments from provideSuccessCases
 
110
 
163
111
        $response = $this->client->post('/dataset/' . $dataSet->dataSetId . '/column', [
164
 
            'heading' => $columnName,
165
 
            'listContent' => $columnListContent,
166
 
            'columnOrder' => $columnOrd,
167
 
            'dataTypeId' => $columnDataTypeId,
168
 
            'dataSetColumnTypeId' => $columnDataSetColumnTypeId,
169
 
            'formula' => $columnFormula
170
 
        ]);
171
 
        # Check that call was successful
172
 
        $this->assertSame(200, $this->client->response->status(), "Not successful: " . $response);
173
 
        $object = json_decode($this->client->response->body());
174
 
        # Check that columns have correct parameters
175
 
        $this->assertObjectHasAttribute('data', $object);
176
 
        $this->assertObjectHasAttribute('id', $object);
177
 
        $this->assertSame($columnName, $object->data->heading);
178
 
        $this->assertSame($columnListContent, $object->data->listContent);
179
 
        $this->assertSame($columnOrd, $object->data->columnOrder);
180
 
        $this->assertSame($columnDataTypeId, $object->data->dataTypeId);
181
 
        $this->assertSame($columnDataSetColumnTypeId, $object->data->dataSetColumnTypeId);
182
 
        $this->assertSame($columnFormula, $object->data->formula);
183
 
        # Check that column was correctly added
184
 
        $column = (new XiboDataSetColumn($this->getEntityProvider()))->getById($dataSet->dataSetId, $object->id);
185
 
        $this->assertSame($columnName, $column->heading);
186
 
        # Clean up the dataset as we no longer need it
187
 
        $this->assertTrue($dataSet->delete(), 'Unable to delete ' . $dataSet->dataSetId);
188
 
    }
189
 
 
190
 
    /**
191
 
     * Each array is a test run
192
 
     * Format ($columnName, $columnListContent, $columnOrd, $columnDataTypeId, $columnDataSetColumnTypeId, $columnFormula)
193
 
     * @return array
194
 
     */
195
 
 
196
 
    public function provideSuccessCases()
197
 
    {
198
 
        # Cases we provide to testAddColumnSucess, you can extend it by simply adding new case here
199
 
        return [
200
 
            # Value
201
 
            'Value String' => ['Test Column Value String', NULL, 2, 1, 1, NULL],
202
 
            'List Content' => ['Test Column list content', 'one,two,three', 2, 1, 1, NULL],
203
 
            'Value Number' => ['Test Column Value Number', NULL, 2, 2, 1, NULL],
204
 
            'Value Date' => ['Test Column Value Date', NULL, 2, 3, 1, NULL],
205
 
            'External Image' => ['Test Column Value External Image', NULL, 2, 4, 1, NULL],
206
 
            'Library Image' => ['Test Column Value Internal Image', NULL, 2, 5, 1, NULL],
207
 
            # Formula
208
 
            'Formula' => ['Test Column Formula', NULL, 2, 5, 1, 'Where Name = Dan'],
209
 
        ];
210
 
    }
211
 
 
212
 
    /**
213
 
     * @dataProvider provideFailureCases
214
 
     */
215
 
    public function testAddColumnFailure($columnName, $columnListContent, $columnOrd, $columnDataTypeId, $columnDataSetColumnTypeId, $columnFormula)
216
 
    {
217
 
        # Create random name and description
218
 
        $name = Random::generateString(8, 'phpunit');
219
 
        $description = 'PHP Unit column add failure';
220
 
        # Create new columns that we expect to fail with arguments from provideFailureCases
221
 
        /** @var XiboDataSet $dataSet */
222
 
        $dataSet = (new XiboDataSet($this->getEntityProvider()))->create($name, $description);
223
 
        $this->client->post('/dataset/' . $dataSet->dataSetId . '/column', [
224
 
            'heading' => $columnName,
225
 
            'listContent' => $columnListContent,
226
 
            'columnOrder' => $columnOrd,
227
 
            'dataTypeId' => $columnDataTypeId,
228
 
            'dataSetColumnTypeId' => $columnDataSetColumnTypeId,
229
 
            'formula' => $columnFormula
230
 
        ]);
231
 
        # Check if cases are failing as expected
232
 
        $this->assertSame(500, $this->client->response->status(), 'Expecting failure, received ' . $this->client->response->status());
233
 
    }
234
 
 
235
 
    /**
236
 
     * Each array is a test run
237
 
     * Format ($columnName, $columnListContent, $columnOrd, $columnDataTypeId, $columnDataSetColumnTypeId, $columnFormula)
238
 
     * @return array
239
 
     */
240
 
 
241
 
    public function provideFailureCases()
242
 
    {
243
 
        # Cases we provide to testAddColumnFailure, you can extend it by simply adding new case here
244
 
        return [
245
 
            // Value
246
 
            'Incorrect dataType' => ['incorrect data type', NULL, 2, 12, 1, NULL],     
247
 
            'Incorrect columnType' => ['incorrect column type', NULL, 2, 19, 1, NULL],   
248
 
            'Empty Name' => [NULL, NULL, 2, 3, 1, NULL]
249
 
        ];
250
 
    }
251
 
 
252
 
    /**
253
 
     * Search columns for DataSet
254
 
     */
255
 
    public function testListAllColumns()
256
 
    {
257
 
        # Create new dataSet
258
 
        $name = Random::generateString(8, 'phpunit');
259
 
        $description = 'PHP Unit column list';
260
 
        $dataSet = (new XiboDataSet($this->getEntityProvider()))->create($name, $description);
261
 
        # Add a new column to our dataset
262
 
        $nameCol = Random::generateString(8, 'phpunit');
263
 
        $dataSet->createColumn($nameCol,'', 2, 1, 1, '');
264
 
        # Search for columns
265
 
        $this->client->get('/dataset/' . $dataSet->dataSetId . '/column');
266
 
        # Check if call was successful
267
 
        $this->assertSame(200, $this->client->response->status());
268
 
        $this->assertNotEmpty($this->client->response->body());
269
 
        $object = json_decode($this->client->response->body());
270
 
        $this->assertObjectHasAttribute('data', $object, $this->client->response->body());
271
 
        # Clean up as we no longer need it
272
 
        $dataSet->delete();
273
 
    }
274
 
 
275
 
    /**
276
 
     * Test edit column
277
 
     */
278
 
    public function testColumnEdit()
279
 
    {
280
 
        # Create dataSet
281
 
        $name = Random::generateString(8, 'phpunit');
282
 
        $description = 'PHP Unit column edit';
283
 
        $dataSet = (new XiboDataSet($this->getEntityProvider()))->create($name, $description);
284
 
        # Add new column to our dataset
285
 
        $nameCol = Random::generateString(8, 'phpunit');
286
 
        $column = (new XiboDataSetColumn($this->getEntityProvider()))->create($dataSet->dataSetId, $nameCol,'', 2, 1, 1, '');
287
 
        # Generate new random name
288
 
        $nameNew = Random::generateString(8, 'phpunit');
289
 
        # Edit our column and change the name
290
 
        $response = $this->client->put('/dataset/' . $dataSet->dataSetId . '/column/' . $column->dataSetColumnId, [
291
 
            'heading' => $nameNew,
 
112
            'heading' => $name,
292
113
            'listContent' => '',
293
 
            'columnOrder' => $column->columnOrder,
294
 
            'dataTypeId' => $column->dataTypeId,
295
 
            'dataSetColumnTypeId' => $column->dataSetColumnTypeId,
 
114
            'columnOrder' => 2,
 
115
            'dataTypeId' => 1,
 
116
            'dataSetColumnTypeId' => 1,
296
117
            'formula' => ''
297
 
        ], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
298
 
        # Check if call was successful
299
 
        $this->assertSame(200, $this->client->response->status(), "Not successful: " . $this->client->response->body());
300
 
        $object = json_decode($this->client->response->body());
301
 
        $this->assertObjectHasAttribute('data', $object);
302
 
        $this->assertObjectHasAttribute('id', $object);
303
 
        # Check if our column has updated name
304
 
        $this->assertSame($nameNew, $object->data->heading);
305
 
        # Clean up as we no longer need it
306
 
        $dataSet->delete();
307
 
    }
308
 
 
309
 
    /**
310
 
     * @param $dataSetId
311
 
     * @depends testAddColumnSuccess
312
 
     */
313
 
    public function testDeleteColumn()
314
 
    {
315
 
        # Create dataSet
316
 
        $name = Random::generateString(8, 'phpunit');
317
 
        $description = 'PHP Unit column delete';
318
 
        $dataSet = (new XiboDataSet($this->getEntityProvider()))->create($name, $description);
319
 
        # Add new column to our dataset
320
 
        $nameCol = Random::generateString(8, 'phpunit');
321
 
        $column = (new XiboDataSetColumn($this->getEntityProvider()))->create($dataSet->dataSetId, $nameCol,'', 2, 1, 1, '');
322
 
        # delete column
323
 
        $response = $this->client->delete('/dataset/' . $dataSet->dataSetId . '/column/' . $column->dataSetColumnId);
324
 
        $this->assertSame(200, $this->client->response->status(), $this->client->response->body());
325
 
    }
326
 
 
327
 
    /*
328
 
    * GET data
329
 
    */
330
 
 
331
 
    public function testGetData()
332
 
    {
333
 
        # Create dataSet
334
 
        $name = Random::generateString(8, 'phpunit');
335
 
        $description = 'PHP Unit';
336
 
        $dataSet = (new XiboDataSet($this->getEntityProvider()))->create($name, $description);
337
 
        # Call get data
338
 
        $this->client->get('/dataset/data/' . $dataSet->dataSetId);
339
 
        # Check if call was successful
340
 
        $this->assertSame(200, $this->client->response->status());
341
 
        $this->assertNotEmpty($this->client->response->body());
342
 
        $object = json_decode($this->client->response->body());
343
 
        $this->assertObjectHasAttribute('data', $object, $this->client->response->body());
344
 
        # Clean up
345
 
        $dataSet->delete();
346
 
    }
347
 
    
348
 
    /**
349
 
     * Test add row
350
 
     */
351
 
    public function testRowAdd()
352
 
    {
353
 
        # Create a new dataset to use
354
 
        $name = Random::generateString(8, 'phpunit');
355
 
        $description = 'PHP Unit row add';
356
 
        /** @var XiboDataSet $dataSet */
357
 
        $dataSet = (new XiboDataSet($this->getEntityProvider()))->create($name, $description);
358
 
        # Create column and add it to our dataset
359
 
        $nameCol = Random::generateString(8, 'phpunit');
360
 
        $column = (new XiboDataSetColumn($this->getEntityProvider()))->create($dataSet->dataSetId, $nameCol,'', 2, 1, 1, '');
361
 
        # Add new row to our dataset and column
362
 
        $response = $this->client->post('/dataset/data/' . $dataSet->dataSetId, [
363
 
            'dataSetColumnId_' . $column->dataSetColumnId => 'test',
364
 
            ]);
365
 
        $this->assertSame(200, $this->client->response->status(), "Not successful: " . $response);
366
 
        $object = json_decode($this->client->response->body());
367
 
        $this->assertObjectHasAttribute('data', $object);
368
 
        $this->assertObjectHasAttribute('id', $object);
369
 
        # Get the row id
370
 
        $row = $dataSet->getDataByRowId($object->id);
371
 
        # Check if data was correctly added to the row
372
 
        $this->assertArrayHasKey($nameCol, $row);
373
 
        $this->assertSame($row[$nameCol], 'test');
374
 
        # Clean up as we no longer need it, deleteWData will delete dataset even if it has data assigned to it
375
 
        $dataSet->deleteWData();
376
 
    }
377
 
    /**
378
 
     * Test edit row
379
 
     * @dataProvider provideSuccessCasesRow
380
 
     */
381
 
    public function testRowEdit($data)
382
 
    {
383
 
        # Create a new dataset to use
384
 
        /** @var XiboDataSet $dataSet */
385
 
        $name = Random::generateString(8, 'phpunit');
386
 
        $description = 'PHP Unit row edit';
387
 
        $dataSet = (new XiboDataSet($this->getEntityProvider()))->create($name, $description);
388
 
        # Generate a new name for the new column
389
 
        $nameCol = Random::generateString(8, 'phpunit');
390
 
        # Create new column and add it to our dataset
391
 
        $column = (new XiboDataSetColumn($this->getEntityProvider()))->create($dataSet->dataSetId, $nameCol,'', 2, 1, 1, '');
392
 
        # Add new row with data to our dataset
393
 
        $rowD = 'test';
394
 
        $row = $dataSet->createRow($column->dataSetColumnId, $rowD);
395
 
        $rowCheck = $dataSet->getDataByRowId($row['id']);
396
 
        # Edit row data
397
 
        $response = $this->client->put('/dataset/data/' . $dataSet->dataSetId . '/' . $row['id'], [
398
 
            'dataSetColumnId_' . $column->dataSetColumnId => $data
399
 
            ], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
400
 
        $this->assertSame(200, $this->client->response->status(), "Not successful: " . $response);
401
 
        $object = json_decode($this->client->response->body());
402
 
        $this->assertObjectHasAttribute('data', $object);
403
 
        $this->assertObjectHasAttribute('id', $object);
404
 
        # get the row id
405
 
        $rowCheck = $dataSet->getDataByRowId($object->id);
406
 
        # Check if data was correctly added to the row
407
 
        $this->assertArrayHasKey($nameCol, $rowCheck);
408
 
        if ($data == Null){
409
 
            $this->assertSame($rowCheck[$nameCol], $rowD);
410
 
        }
411
 
        else {
412
 
         $this->assertSame($rowCheck[$nameCol], $data);           
413
 
        }
414
 
        # Clean up as we no longer need it, deleteWData will delete dataset even if it has data assigned to it
415
 
        $dataSet -> deleteWData();
416
 
    }
417
 
 
418
 
    /**
419
 
     * Each array is a test run
420
 
     * Format ($data)
421
 
     * @return array
422
 
     */
423
 
 
424
 
    public function provideSuccessCasesRow()
425
 
    {
426
 
        # Cases we provide to testRowEdit, you can extend it by simply adding new case here
427
 
        return [
428
 
            # Value
429
 
            'String' => ['API EDITED ROW'],
430
 
            'Null' => [NULL],
431
 
            'number as string' => ['1212']
432
 
        ];
433
 
    }
434
 
 
435
 
    /*
436
 
    * delete row data
437
 
    */
438
 
    public function testRowDelete()
439
 
    {
440
 
        # Create a new dataset to use
441
 
        /** @var XiboDataSet $dataSet */
442
 
        $name = Random::generateString(8, 'phpunit');
443
 
        $description = 'PHP Unit row delete';
444
 
        $dataSet = (new XiboDataSet($this->getEntityProvider()))->create($name, $description);
445
 
        # Generate a new name for the new column
446
 
        $nameCol = Random::generateString(8, 'phpunit');
447
 
        # Create new column and add it to our dataset
448
 
        $column = (new XiboDataSetColumn($this->getEntityProvider()))->create($dataSet->dataSetId, $nameCol,'', 2, 1, 1, '');
449
 
        # Add new row data
450
 
        $row = $dataSet->createRow($column->dataSetColumnId, 'test');
451
 
        $rowCheck = $dataSet->getDataByRowId($row['id']);
452
 
        # Delete row
453
 
        $this->client->delete('/dataset/data/' . $dataSet->dataSetId . '/' . $row['id']);
454
 
        $response = json_decode($this->client->response->body());
455
 
        $this->assertSame(204, $response->status, $this->client->response->body());
456
 
        # Clean up as we no longer need it, deleteWData will delete dataset even if it has data assigned to it
457
 
        $dataSet -> deleteWData();
458
 
    }
459
 
}
 
118
        ]);
 
119
 
 
120
        $this->assertSame(200, $this->client->response->status(), "Not successful: " . $response);
 
121
 
 
122
        $object = json_decode($this->client->response->body());
 
123
 
 
124
        $this->assertObjectHasAttribute('data', $object);
 
125
        $this->assertObjectHasAttribute('id', $object);
 
126
        $this->assertSame($name, $object->data->heading);
 
127
        return $object->id;
 
128
    }
 
129
}
 
 
b'\\ No newline at end of file'