You are here

public function vfsStreamDirectoryTestCase::childHandlingWithSubdirectory in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamDirectoryTestCase.php \org\bovigo\vfs\vfsStreamDirectoryTestCase::childHandlingWithSubdirectory()

test that adding, handling and removing of a child works as expected

@test

File

vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamDirectoryTestCase.php, line 187

Class

vfsStreamDirectoryTestCase
Test for org\bovigo\vfs\vfsStreamDirectory.

Namespace

org\bovigo\vfs

Code

public function childHandlingWithSubdirectory() {
  $mockChild = $this
    ->getMock('org\\bovigo\\vfs\\vfsStreamContent');
  $mockChild
    ->expects($this
    ->any())
    ->method('getType')
    ->will($this
    ->returnValue(vfsStreamContent::TYPE_FILE));
  $mockChild
    ->expects($this
    ->any())
    ->method('getName')
    ->will($this
    ->returnValue('bar'));
  $mockChild
    ->expects($this
    ->once())
    ->method('size')
    ->will($this
    ->returnValue(5));
  $subdir = new vfsStreamDirectory('subdir');
  $subdir
    ->addChild($mockChild);
  $this->dir
    ->addChild($subdir);
  $this
    ->assertTrue($this->dir
    ->hasChild('subdir'));
  $this
    ->assertSame($subdir, $this->dir
    ->getChild('subdir'));
  $this
    ->assertEquals(array(
    $subdir,
  ), $this->dir
    ->getChildren());
  $this
    ->assertEquals(0, $this->dir
    ->size());
  $this
    ->assertEquals(5, $this->dir
    ->sizeSummarized());
  $this
    ->assertTrue($this->dir
    ->removeChild('subdir'));
  $this
    ->assertEquals(array(), $this->dir
    ->getChildren());
  $this
    ->assertEquals(0, $this->dir
    ->size());
  $this
    ->assertEquals(0, $this->dir
    ->sizeSummarized());
}