1<?php 2/** 3 * Copyright 2010-2017 Horde LLC (http://www.horde.org/) 4 * 5 * @author Jan Schneider <jan@horde.org> 6 * @category Horde 7 * @package Share 8 * @subpackage UnitTests 9 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 10 */ 11class Horde_Share_Test_Sqlng_Base extends Horde_Share_TestBase 12{ 13 protected static $db; 14 15 protected static $reason; 16 17 public function testGetApp() 18 { 19 $this->getApp('test'); 20 } 21 22 public function testSetTable() 23 { 24 $this->assertEquals('test_sharesng', self::$share->getTable()); 25 self::$share->setTable('foo'); 26 $this->assertEquals('foo', self::$share->getTable()); 27 self::$share->setTable('test_shares'); 28 } 29 30 public function testSetStorage() 31 { 32 self::$share->setStorage(self::$db); 33 $this->assertEquals(self::$db, self::$share->getStorage()); 34 } 35 36 public function testAddShare() 37 { 38 $share = parent::addShare(); 39 $this->assertInstanceOf('Horde_Share_Object_Sqlng', $share); 40 } 41 42 /** 43 * @depends testAddShare 44 */ 45 public function testPermissions() 46 { 47 parent::permissions(); 48 } 49 50 /** 51 * @depends testAddShare 52 */ 53 public function testExists() 54 { 55 parent::exists(); 56 } 57 58 /** 59 * @depends testPermissions 60 */ 61 public function testCountShares() 62 { 63 parent::countShares(); 64 } 65 66 /** 67 * @depends testPermissions 68 */ 69 public function testGetShare() 70 { 71 $share = parent::getShare(); 72 $this->assertInstanceOf('Horde_Share_Object_Sqlng', $share); 73 } 74 75 /** 76 * @depends testGetShare 77 */ 78 public function testGetShareById() 79 { 80 parent::getShareById(); 81 } 82 83 /** 84 * @depends testGetShare 85 */ 86 public function testGetShares() 87 { 88 parent::getShares(); 89 } 90 91 /** 92 */ 93 public function testGetParent() 94 { 95 $share = self::$share->getShare('myshare'); 96 $child = self::$share->getShare('mychildshare'); 97 $this->assertEquals($share->getId(), $child->getParent()->getId()); 98 } 99 100 /** 101 * @depends testPermissions 102 */ 103 public function testListOwners() 104 { 105 $owners = self::$share->listOwners(); 106 $this->assertInternalType('array', $owners); 107 $this->assertTrue(in_array('john', $owners)); 108 } 109 110 /** 111 * @depends testPermissions 112 */ 113 public function testCountOwners() 114 { 115 $count = self::$share->countOwners(); 116 $this->assertTrue($count > 0); 117 } 118 119 /** 120 * @depends testPermissions 121 */ 122 public function testListAllShares() 123 { 124 parent::listAllShares(); 125 } 126 127 /** 128 * @depends testPermissions 129 */ 130 public function testListShares() 131 { 132 parent::listShares(); 133 } 134 135 /** 136 * @depends testPermissions 137 */ 138 public function testListSystemShares() 139 { 140 parent::listSystemShares(); 141 } 142 143 /** 144 * @depends testPermissions 145 */ 146 public function testGetPermission() 147 { 148 return $this->getPermission(); 149 } 150 151 /** 152 * @depends testPermissions 153 */ 154 public function testRemoveUserPermissions() 155 { 156 return parent::removeUserPermissions(); 157 } 158 159 /** 160 * @depends testRemoveUserPermissions 161 */ 162 public function testRemoveGroupPermissions() 163 { 164 parent::removeGroupPermissions(); 165 } 166 167 /** 168 * @depends testGetShare 169 */ 170 public function testRemoveShare() 171 { 172 parent::removeShare(); 173 } 174 175 /** 176 * @depends testGetShare 177 */ 178 public function testRenameShare() 179 { 180 parent::renameShare(); 181 } 182 183 public function testCallback() 184 { 185 $this->callbackSetShareOb(new Horde_Share_Object_Sqlng(array())); 186 } 187 188 public static function setUpBeforeClass() 189 { 190 require_once __DIR__ . '/../migration/sqlng.php'; 191 migrate_sqlng(self::$db); 192 193 $group = new Horde_Share_Stub_Group(); 194 self::$share = new Horde_Share_Sqlng('test', 'john', new Horde_Perms_Sql(array('db' => self::$db)), $group); 195 self::$share->setStorage(self::$db); 196 197 // FIXME 198 $GLOBALS['injector'] = new Horde_Injector(new Horde_Injector_TopLevel()); 199 $GLOBALS['injector']->setInstance('Horde_Group', $group); 200 } 201 202 public static function tearDownAfterClass() 203 { 204 if (self::$db) { 205 $migration = new Horde_Db_Migration_Base(self::$db); 206 $migration->dropTable('test_shares'); 207 $migration->dropTable('test_shares_groups'); 208 $migration->dropTable('test_shares_users'); 209 self::$db->disconnect(); 210 self::$db = null; 211 } 212 } 213 214 public function setUp() 215 { 216 if (!self::$db) { 217 $this->markTestSkipped(self::$reason); 218 } 219 } 220} 221