~ubuntu-branches/ubuntu/vivid/php-horde-nag/vivid-proposed

« back to all changes in this revision

Viewing changes to nag-4.1.3/test/Nag/Unit/Nag/Base.php

  • Committer: Package Import Robot
  • Author(s): Mathieu Parent
  • Date: 2014-03-11 21:27:39 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20140311212739-m6rbihspu5zjpvaq
Tags: 4.1.4-1
New upstream version 4.1.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/**
3
 
 * Test the core Nag class with various backends.
4
 
 *
5
 
 * PHP version 5
6
 
 *
7
 
 * @category   Horde
8
 
 * @package    Nag
9
 
 * @subpackage UnitTests
10
 
 * @author     Gunnar Wrobel <wrobel@pardus.de>
11
 
 * @link       http://www.horde.org/apps/nag
12
 
 * @license    http://www.horde.org/licenses/gpl GNU General Public License, version 2
13
 
 */
14
 
 
15
 
/**
16
 
 * Test the core Nag class with various backends.
17
 
 *
18
 
 * Copyright 2011-2013 Horde LLC (http://www.horde.org/)
19
 
 *
20
 
 * See the enclosed file COPYING for license information (GPLv2). If you did not
21
 
 * receive this file, see http://www.horde.org/licenses/gpl
22
 
 *
23
 
 * @category   Horde
24
 
 * @package    Nag
25
 
 * @subpackage UnitTests
26
 
 * @author     Gunnar Wrobel <wrobel@pardus.de>
27
 
 * @link       http://www.horde.org/apps/nag
28
 
 * @license    http://www.horde.org/licenses/gpl GNU General Public License, version 2
29
 
 */
30
 
class Nag_Unit_Nag_Base extends Nag_TestCase
31
 
{
32
 
    /**
33
 
     * The test setup.
34
 
     *
35
 
     * @var Horde_Test_Setup
36
 
     */
37
 
    static $setup;
38
 
 
39
 
    /**
40
 
     * The default share name expected to be used.
41
 
     *
42
 
     * @var string
43
 
     */
44
 
    protected $default_name = 'Task list of test@example.com';
45
 
 
46
 
    public static function setUpBeforeClass()
47
 
    {
48
 
        self::createBasicNagSetup(self::$setup);
49
 
        parent::setUpBeforeClass();
50
 
    }
51
 
 
52
 
    public function setUp()
53
 
    {
54
 
        $error = self::$setup->getError();
55
 
        if (!empty($error)) {
56
 
            $this->markTestSkipped($error);
57
 
        }
58
 
    }
59
 
 
60
 
    public function tearDown()
61
 
    {
62
 
        foreach ($GLOBALS['nag_shares']->listShares('test@example.com') as $share) {
63
 
            $GLOBALS['nag_shares']->removeShare($share);
64
 
        }
65
 
        $GLOBALS['injector']->setInstance('Nag_Factory_Tasklists', null);
66
 
        parent::tearDown();
67
 
    }
68
 
 
69
 
    public function testCreateDefaultShare()
70
 
    {
71
 
        $GLOBALS['conf']['share']['auto_create'] = true;
72
 
        Nag::initialize();
73
 
        $this->assertEquals(1, count($GLOBALS['display_tasklists']));
74
 
    }
75
 
 
76
 
    public function testDefaultShareName()
77
 
    {
78
 
        $GLOBALS['conf']['share']['auto_create'] = true;
79
 
        Nag::initialize();
80
 
        $shares = $GLOBALS['nag_shares']->listShares('test@example.com');
81
 
        $default = array_pop($shares);
82
 
        $this->assertEquals(
83
 
            $this->default_name,
84
 
            $default->get('name')
85
 
        );
86
 
    }
87
 
 
88
 
    public function testNoAutoCreate()
89
 
    {
90
 
        $GLOBALS['conf']['share']['auto_create'] = false;
91
 
        Nag::initialize();
92
 
        $this->assertEquals(0, count($GLOBALS['display_tasklists']));
93
 
    }
94
 
 
95
 
    public function testDefaultShareDeletePermission()
96
 
    {
97
 
        $GLOBALS['conf']['share']['auto_create'] = true;
98
 
        Nag::initialize();
99
 
        $shares = $GLOBALS['nag_shares']->listShares('test@example.com');
100
 
        $default = array_pop($shares);
101
 
        $this->assertTrue(
102
 
            $default->hasPermission(
103
 
                $GLOBALS['registry']->getAuth(), Horde_Perms::DELETE
104
 
            )
105
 
        );
106
 
    }
107
 
 
108
 
}