1<?php
2/**
3 * Test the search operations by mail.
4 *
5 * PHP version 5
6 *
7 * @category Kolab
8 * @package  Kolab_Server
9 * @author   Gunnar Wrobel <wrobel@pardus.de>
10 * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
11 * @link     http://pear.horde.org/index.php?package=Kolab_Server
12 */
13
14/**
15 * Require our basic test case definition
16 */
17require_once __DIR__ . '/../../../../TestCase.php';
18
19/**
20 * Test the search operations by mail.
21 *
22 * Copyright 2009-2016 Horde LLC (http://www.horde.org/)
23 *
24 * See the enclosed file COPYING for license information (LGPL). If you
25 * did not receive this file, see http://www.horde.org/licenses/lgpl21.
26 *
27 * @category Kolab
28 * @package  Kolab_Server
29 * @author   Gunnar Wrobel <wrobel@pardus.de>
30 * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
31 * @link     http://pear.horde.org/index.php?package=Kolab_Server
32 */
33class Horde_Kolab_Server_Class_Server_Search_Operation_GuidformailTest
34extends Horde_Kolab_Server_TestCase
35{
36    public function setUp()
37    {
38        $this->structure = $this->getMock('Horde_Kolab_Server_Structure_Interface');
39    }
40
41    public function testMethodRestrictkolabHasResultRestrictedToKolabUsers()
42    {
43        $result = $this->getMock('Horde_Kolab_Server_Result_Interface');
44        $result->expects($this->once())
45            ->method('asArray')
46            ->will($this->returnValue(array('a' => 'a')));
47        $this->structure->expects($this->once())
48            ->method('find')
49            ->with(
50                $this->logicalAnd(
51                    $this->isRestrictedToKolabUsers(),
52                    $this->isSearchingByMail()
53                ),
54                array('attributes' => 'guid')
55            )
56            ->will($this->returnValue($result));
57        $search = new Horde_Kolab_Server_Search_Operation_Guidformail($this->structure);
58        $criteria = $this->getMock('Horde_Kolab_Server_Query_Element_Interface');
59        $this->assertEquals(array('a'), $search->searchGuidForMail('test'));
60    }
61}