/** * @return void */ public function testBasicOutput() { $this->Comments->removeBehavior('String'); $data = ['title' => 'some Name', 'comment' => 'blabla', 'url' => '']; $entity = $this->Comments->newEntity($data); $res = $this->Comments->save($entity); $this->assertTrue((bool) $res); $this->Comments->addBehavior('Tools.String', ['fields' => ['title'], 'output' => ['ucfirst']]); $res = $this->Comments->get($entity->id); $this->assertSame('Some Name', $res['title']); }
/** * @return void */ public function testEncodeWithNoParamsComplexContent() { $this->Comments->removeBehavior('Jsonable'); $this->Comments->addBehavior('Tools.Jsonable', ['output' => 'array', 'fields' => ['details'], 'encodeParams' => ['options' => 0]]); $data = ['comment' => 'blabla', 'url' => 'www.dereuromark.de', 'title' => 'param', 'details' => ['foo' => 'bar', 'nan' => NAN, 'inf' => INF]]; $entity = $this->Comments->newEntity($data); $result = $this->Comments->save($entity); $this->assertTrue((bool) $result); $res = $this->Comments->get($entity->id); $expected = []; $this->assertSame($expected, $res->details); }