/**
  * Test getting and setting the keys.
  *
  * @return void
  */
 public function testKeys()
 {
     // Returns the keys array if nothing is passed in.
     $this->assertEmpty($this->subject->keys());
     // Returns $this if setting keys.
     $this->assertInstanceOf(BaseTransformer::class, $this->subject->keys(['id', 'name']));
     $this->assertEquals(['id', 'name'], $this->subject->keys());
     // If the keys are not empty it merges instead of replacing the keys
     $this->assertEquals(['id', 'name', 'lang'], $this->subject->keys(['lang'])->keys());
 }
Example #2
0
 /**
  * Transformer constructor.
  *
  * @param Model|\Illuminate\Support\Collection $item
  * @param bool $childTransformation
  */
 public function __construct($item = null, $childTransformation = false)
 {
     parent::__construct($item);
     $this->childTransformation = $childTransformation;
 }