/** * @param int $id * @param array|UnitUpdateTransfer $data * @return bool */ public function update($id, $data) { if (!$data instanceof UnitUpdateTransfer) { if (!is_array($data)) { throw new InvalidArgumentException('Data argument should be an array of instance of UnitUpdateTransfer'); } $data = UnitUpdateTransfer::make($data); } $endpoint = new Update($this->getTransport()); $endpoint->setId($id); $endpoint->setTransfer($data); try { $result = $endpoint->performRequest(); } catch (ResourceNotFoundException $e) { return false; } return $result['status'] == 204; }
public function testUpdate() { $this->transport->shouldReceive('performRequest')->once()->withArgs(['PATCH', 'units/10/', [], ['condition' => 'new'], \Mockery::any()])->andReturn(['status' => 204]); $namespace = new UnitsNamespace($this->transport); $result = $namespace->update(10, UnitUpdateTransfer::make(['condition' => 'new'])); $this->assertTrue($result); }