/usr/share/php/tests/nag/Nag/Unit/Form/Task/Base.php is in php-horde-nag 4.1.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | <?php
/**
* Test the task form.
*
* PHP version 5
*
* @category Horde
* @package Nag
* @subpackage UnitTests
* @author Gunnar Wrobel <wrobel@pardus.de>
* @link http://www.horde.org/apps/nag
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
/**
* Test the task form.
*
* Copyright 2011-2013 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPLv2). If you did not
* receive this file, see http://www.horde.org/licenses/gpl
*
* @category Horde
* @package Nag
* @subpackage UnitTests
* @author Gunnar Wrobel <wrobel@pardus.de>
* @link http://www.horde.org/apps/nag
* @license http://www.horde.org/licenses/gpl GNU General Public License, version 2
*/
class Nag_Unit_Form_Task_Base extends Nag_TestCase
{
/**
* The test setup.
*
* @var Horde_Test_Setup
*/
static $setup;
private $_old_errorreporting;
public static function setUpBeforeClass()
{
self::$setup = new Horde_Test_Setup();
self::createBasicNagSetup(self::$setup);
parent::setUpBeforeClass();
}
public function setUp()
{
$error = self::$setup->getError();
if (!empty($error)) {
$this->markTestSkipped($error);
}
$this->_old_errorreporting = error_reporting(E_ALL & ~(E_STRICT | E_DEPRECATED));
error_reporting(E_ALL & ~(E_STRICT | E_DEPRECATED));
parent::setUp();
}
public function tearDown()
{
error_reporting($this->_old_errorreporting);
parent::tearDown();
}
public function testSingleAssignee()
{
$share = array_shift($GLOBALS['nag_shares']->listShares('test@example.com'));
$vars = Horde_Variables::getDefaultVariables();
$vars->set('tasklist_id', $share->getName());
$form = new Nag_Form_Task($vars, _("New Task"));
$this->assertEquals(
array('test@example.com' => 'test@example.com'),
$this->_getAssignees($form)
);
}
public function testTwoAssignees()
{
$share = array_shift($GLOBALS['nag_shares']->listShares('test@example.com'));
$share = $GLOBALS['nag_shares']->getShare($share->getName());
$share->addUserPermission('jane', Horde_Perms::READ);
$vars = Horde_Variables::getDefaultVariables();
$vars->set('tasklist_id', $share->getName());
$form = new Nag_Form_Task($vars, _("New Task"));
$this->assertEquals(
array('jane' => 'jane', 'test@example.com' => 'test@example.com'),
$this->_getAssignees($form)
);
}
private function _getAssignees($form)
{
$result = false;
foreach ($form->getVariables() as $var) {
if ($var->getVarName() == 'assignee') {
$result = $var;
break;
}
}
$this->assertTrue($var !== false);
return $var->getType()->getValues();
}
}
|