/** * get unique id for one or all messages * * if storage does not support unique ids it's the same as the message number * * @param int|null $id message number * @return array|string message number for given message or all messages as array * @throws \Zend\Mail\Storage\Exception */ public function getUniqueId($id = null) { if ($id) { return $this->_protocol->fetch('UID', $id); } return $this->_protocol->fetch('UID', 1, INF); }
public function testFetch() { $protocol = new Protocol\Imap($this->_params['host']); $protocol->login($this->_params['user'], $this->_params['password']); $protocol->select('INBOX'); $range = array_combine(range(1, 7), range(1, 7)); $this->assertEquals($protocol->fetch('UID', 1, INF), $range); $this->assertEquals($protocol->fetch('UID', 1, 7), $range); $this->assertEquals($protocol->fetch('UID', range(1, 7)), $range); $this->assertTrue(is_numeric($protocol->fetch('UID', 1))); $result = $protocol->fetch(array('UID', 'FLAGS'), 1, INF); foreach ($result as $k => $v) { $this->assertEquals($k, $v['UID']); $this->assertTrue(is_array($v['FLAGS'])); } try { $protocol->fetch('UID', 99); } catch (\Exception $e) { return; // ok } $this->fail('no exception while fetching message'); }
public function testFetch() { $protocol = new Protocol\Imap($this->_params['host']); $protocol->login($this->_params['user'], $this->_params['password']); $protocol->select('INBOX'); $range = array_combine(range(1, 7), range(1, 7)); $this->assertEquals($protocol->fetch('UID', 1, INF), $range); $this->assertEquals($protocol->fetch('UID', 1, 7), $range); $this->assertEquals($protocol->fetch('UID', range(1, 7)), $range); $this->assertTrue(is_numeric($protocol->fetch('UID', 1))); $result = $protocol->fetch(array('UID', 'FLAGS'), 1, INF); foreach ($result as $k => $v) { $this->assertEquals($k, $v['UID']); $this->assertTrue(is_array($v['FLAGS'])); } $this->setExpectedException('Zend\\Mail\\Storage\\Exception\\InvalidArgumentException'); $protocol->fetch('UID', 99); }