9 # create a factory tied to a specified owner 12 # verify that they currently have no folders 13 $this->assertSame(0, $Factory->GetFolderCount() );
15 # create a folder for them and verify that the count incrases 16 $Factory->CreateFolder(self::TYPE_NAME,
"Test Folder 1", self::OWNER_ID);
17 $this->assertSame(1, $Factory->GetFolderCount() );
19 # create a second folder, verify that goes up as well 20 $Factory->CreateFolder(self::TYPE_NAME,
"Test Folder 2", self::OWNER_ID);
21 $this->assertSame(2, $Factory->GetFolderCount());
23 # get our folder by name 24 $Folder = $Factory->GetFolderByNormalizedName(
"testfolder1");
25 $this->assertTrue($Folder instanceof
Folder);
27 # get our folder using GetFolders with a name argument 28 $MatchingFolders = $Factory->GetFolders(
29 self::TYPE_NAME, self::OWNER_ID,
"Test Folder 1");
30 $this->assertSame(1, count($MatchingFolders) );
31 $this->assertSame(current($MatchingFolders)->Id(), $Folder->Id() );
33 # get our folder using GetFolders with a count argument 34 $MatchingFolders = $Factory->GetFolders(
35 self::TYPE_NAME, self::OWNER_ID, NULL, 0, 1);
36 $this->assertSame(1, count($MatchingFolders) );
37 $this->assertSame(current($MatchingFolders)->Id(), $Folder->Id() );
42 # verify that the folder is now gone 43 $Folder = $Factory->GetFolderByNormalizedName(
"testfolder1");
44 $this->assertNull($Folder);
46 # get our remaining test folder, give it an item 47 $Folder = $Factory->GetFolderByNormalizedName(
"testfolder2");
48 $Folder->AppendItem(1);
50 # search for that folder using GetFoldersContainingItem 51 $MatchingFolders = $Factory->GetFoldersContainingItem(1, self::TYPE_NAME);
52 $this->assertSame(1, count($MatchingFolders) );
53 $this->assertSame(current($MatchingFolders)->Id(), $Folder->Id() );
55 # clean up our remaining test folder 57 $this->assertSame(0, $Factory->GetFolderCount() );
66 $DB->Query(
"DELETE FROM Folders WHERE OwnerId = ".self::OWNER_ID);
67 $DB->Query(
"DELETE FROM FolderContentTypes WHERE " 68 .
"TypeName='".self::TYPE_NAME.
"' ");
77 $DB->Query(
"DELETE FROM Folders WHERE OwnerId = ".self::OWNER_ID);
78 $DB->Query(
"DELETE FROM FolderContentTypes WHERE " 79 .
"TypeName='".self::TYPE_NAME.
"' ");
SQL database abstraction object with smart query caching.
Factory object for Folder class, used to retrieve and manage Folders and groups of Folders...
Folder object used to create and manage groups of items.
static tearDownAfterClass()
Destroy tables created for testing.
static setUpBeforeClass()
Destroy tables created for testing.