/** * @param array|CategoryDecideTransfer $data * @return array|CategoryTransfer[] */ public function decide($data) { if (!$data instanceof CategoryDecideTransfer) { if (!is_array($data)) { throw new InvalidArgumentException('Data argument should be an array of instance of CategoryDecideTransfer'); } $data = CategoryDecideTransfer::make($data); } $endpoint = new Decide($this->getTransport()); $endpoint->setTransfer($data); $resultRequest = $endpoint->performRequest(); Response::checkBody($resultRequest); $result = []; foreach ($resultRequest['json'] as $item) { $result[] = CategoryTransfer::make($item); } return $result; }
public function testInstance() { /** @var \Mockery\Mock|\Hitmeister\Component\Api\Transfers\CategoryDecideTransfer $transfer */ $transfer = \Mockery::mock('\\Hitmeister\\Component\\Api\\Transfers\\CategoryDecideTransfer'); $transfer->shouldReceive('toArray')->once()->andReturn(['item' => 'value']); $decide = new Decide($this->transport); $decide->setTransfer($transfer); $this->assertInstanceOf('\\Hitmeister\\Component\\Api\\Transfers\\CategoryDecideTransfer', $decide->getTransfer()); $this->assertEquals([], $decide->getParamWhiteList()); $this->assertEquals('POST', $decide->getMethod()); $this->assertEquals('categories/decide/', $decide->getURI()); $this->assertArrayHasKey('item', $decide->getBody()); }