/** * testUpdate method * * @return vod */ public function testUpdate() { $data = array('unit' => array('label' => 'Foo', 'symbol' => 'F')); $m2x = $this->generateMockM2X(); $m2x->request->expects($this->at(0))->method('request')->with($this->equalTo('PUT'), $this->equalTo('https://api-m2x.att.com/v2/devices/c2b83dcb796230906c70854a57b66b0a/streams/stream_foo'), $this->equalTo(array()), $this->equalTo($data))->willReturn(new Att\M2X\HttpResponse($this->_raw('streams_update_success'))); $m2x->request->expects($this->at(1))->method('request')->with($this->equalTo('GET'), $this->equalTo('https://api-m2x.att.com/v2/devices/c2b83dcb796230906c70854a57b66b0a/streams/stream_foo'))->willReturn(new Att\M2X\HttpResponse($this->_raw('streams_update_get'))); $device = new Device($m2x, array('id' => 'c2b83dcb796230906c70854a57b66b0a')); $result = $device->updateStream('stream_foo', $data); $this->assertInstanceOf('Att\\M2X\\Stream', $result); $this->assertSame($device, $result->parent); }
/** * testValuesExport method * * @return void */ public function testValuesExport() { $m2x = $this->generateMockM2X(); $m2x->request->expects($this->once())->method('request')->with($this->equalTo('GET'), $this->equalTo('https://api-m2x.att.com/v2/devices/foo/values/export.csv'), $this->equalTo(array('streams' => 'foo,bar')))->willReturn(new Att\M2X\HttpResponse($this->_raw('devices_get_values_export'))); $device = new Device($m2x, array('id' => 'foo')); $result = $device->valuesExport(array('streams' => 'foo,bar')); $this->assertInstanceOf('Att\\M2X\\HttpResponse', $result); $expected = 'http://api-m2x.att.com/v2/jobs/201512b934abb4fc68dedbc05ef052c6cff8f0'; $this->assertEquals($expected, $result->headers['Location']); }
/** * Create a new device. * * @link https://m2x.att.com/developer/documentation/v2/device#Create-Device * * @param array $data * @return Device */ public function createDevice($data) { return Device::create($this, $data); }