Skip to content
Permalink
Browse files

Add test for accessibleFields option in Marshaller::one().

Add a test to test how the new option works in both the additive and
subtractive cases.
  • Loading branch information...
markstory committed Sep 10, 2014
1 parent c046355 commit c79f240637907f3a1954349b5768e24700875243
Showing with 29 additions and 0 deletions.
  1. +29 −0 tests/TestCase/ORM/MarshallerTest.php
@@ -205,6 +205,35 @@ public function testOneAccessibleProperties() {
$this->assertNull($result->not_in_schema);
}
/**
* Test one() supports accessibleFields option
*
* @return void
*/
public function testOneAccessibleFieldsOption() {
$data = [
'title' => 'My title',
'body' => 'My content',
'author_id' => 1,
'not_in_schema' => true
];
$this->articles->entityClass(__NAMESPACE__ . '\ProtectedArticle');
$marshall = new Marshaller($this->articles);
$result = $marshall->one($data, ['accessibleFields' => ['body' => false]]);
$this->assertNull($result->body);
$result = $marshall->one($data, ['accessibleFields' => ['author_id' => true]]);
$this->assertEquals($data['author_id'], $result->author_id);
$this->assertNull($result->not_in_schema);
$result = $marshall->one($data, ['accessibleFields' => ['*' => true]]);
$this->assertEquals($data['author_id'], $result->author_id);
$this->assertTrue($result->not_in_schema);
}
/**
* test one() with a wrapping model name.
*

0 comments on commit c79f240

Please sign in to comment.
You can’t perform that action at this time.