Skip to content

Commit

Permalink
Merge pull request #1571 from stefanorosanelli/issue/v4/1568-patch-pr…
Browse files Browse the repository at this point in the history
…operty-types

Issue/v4/1568 patch property types
  • Loading branch information
batopa committed Dec 10, 2018
2 parents 6b416b0 + 9366e4e commit 5614e85
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,20 @@ public function testEdit()

$this->configRequestHeaders('PATCH', $this->getUserAuthHeader());
$this->patch('/model/properties/1', json_encode(compact('data')));
$result = json_decode((string)$this->_response->getBody(), true);

$this->assertResponseCode(200);
$this->assertContentType('application/vnd.api+json');

unset($result['data']['meta']);
$data['attributes'] += [
'label' => null,
'is_nullable' => true,
'property_type_name' => 'string',
'object_type_name' => 'documents',
];
static::assertEquals($data, $result['data']);

static::assertEquals('nice description', TableRegistry::get('Properties')->get(1)->get('description'));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,12 @@ public function testEdit()

$this->configRequestHeaders('PATCH', $this->getUserAuthHeader());
$this->patch('/model/property_types/1', json_encode(compact('data')));
$result = json_decode((string)$this->_response->getBody(), true);

$this->assertResponseCode(200);
$this->assertContentType('application/vnd.api+json');
unset($result['data']['relationships']);
static::assertEquals($data, $result['data']);
static::assertEquals($data['attributes']['params'], TableRegistry::get('PropertyTypes')->get(1)->get('params'));
}

Expand Down
2 changes: 2 additions & 0 deletions plugins/BEdita/Core/config/reserved.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@
'trees',
'tree_nodes',
'tree_parent_nodes',
'type',
'types',
];
1 change: 1 addition & 0 deletions plugins/BEdita/Core/src/Model/Entity/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class Property extends Entity implements JsonApiSerializable
'modified' => false,
'default' => false,
'required' => false,
'type' => false,
];

/**
Expand Down
10 changes: 9 additions & 1 deletion plugins/BEdita/Core/src/Model/Entity/PropertyType.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
*/
class PropertyType extends Entity implements JsonApiSerializable
{

use JsonApiModelTrait;

/**
* {@inheritDoc}
*/
protected $_accessible = [
'*' => false,
'name' => true,
'params' => true,
];
}

0 comments on commit 5614e85

Please sign in to comment.