first() public method

Return the first fetch object in the results, if there is only one object.
public first ( ) : null | Horde_Imap_Client_Data_Fetch
return null | Horde_Imap_Client_Data_Fetch The fetch object if there is only one object, or null.
Beispiel #1
0
 public function testFirst()
 {
     $this->assertNull($this->ob->first());
     $ob = new Horde_Imap_Client_Fetch_Results($this->ob_class);
     $fetch = $ob->get('1');
     $this->assertEquals($fetch, $ob->first());
 }
Beispiel #2
0
 public function testBug11946()
 {
     $test = array('* 1 FETCH (FLAGS (\\Seen \\Flagged))', '* 1 FETCH (UID 9)');
     $res = new Horde_Imap_Client_Fetch_Results();
     $this->test_ob->parseFetch($test[0], array('results' => $res));
     $this->test_ob->parseFetch($test[1], array('results' => $res));
     $this->assertEquals(array('\\seen', '\\flagged'), $res->first()->getFlags());
     $this->assertEquals(9, $res->first()->getUid());
     $test[1] = '* 1 FETCH (UID 9 FLAGS (\\Seen \\Flagged))';
     $res = new Horde_Imap_Client_Fetch_Results();
     $this->test_ob->parseFetch($test[0], array('results' => $res));
     $this->test_ob->parseFetch($test[1], array('results' => $res));
     $this->assertEquals(array('\\seen', '\\flagged'), $res->first()->getFlags());
 }