public function testGetDirectory() { $root = new \core_kernel_classes_Class($this->rootClass); //Remove what has been done $subclasses = $root->getSubClasses(); foreach ($subclasses as $subclass) { $subclass->delete(true); } $root->delete(); $root->setLabel('myRootClass'); $acceptableMime = array(); $depth = 1; $directory = $this->mediaManagerManagement->getDirectory($this->rootClass, $acceptableMime, $depth); $this->assertInternalType('array', $directory, 'The result should be an array'); $this->assertArrayHasKey('label', $directory, 'The result should contain "label"'); $this->assertArrayHasKey('path', $directory, 'The result should contain "path"'); $this->assertArrayHasKey('children', $directory, 'The result should contain "children"'); $this->assertInternalType('array', $directory['children'], 'Children should be an array'); $this->assertEmpty($directory['children'], 'Children should be empty'); $this->assertEquals('myRootClass', $directory['label'], 'The label is not correct'); $this->assertEquals('taomedia://mediamanager/' . \tao_helpers_Uri::encode($this->rootClass), $directory['path'], 'The path is not correct'); $root->createSubClass('mySubClass1'); $root->createSubClass('mySubClass0'); $newDirectory = $this->mediaManagerManagement->getDirectory($this->rootClass, $acceptableMime, $depth); $this->assertInternalType('array', $newDirectory['children'], 'Children should be an array'); $this->assertNotEmpty($newDirectory['children'], 'Children should not be empty'); $labels = array(); foreach ($newDirectory['children'] as $i => $child) { $this->assertInternalType('array', $child, 'The result should be an array'); $this->assertArrayHasKey('label', $child, 'The result should contain "label"'); $this->assertArrayHasKey('path', $child, 'The result should contain "path"'); $labels[] = $child['label']; } $this->assertEquals(2, count($labels)); $this->assertContains('mySubClass0', $labels); $this->assertContains('mySubClass1', $labels); //Remove what has been done $subclasses = $root->getSubClasses(); foreach ($subclasses as $subclass) { $subclass->delete(); } $root->delete(); }