You are here

class vfsStreamAbstractVisitorTestCase in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/visitor/vfsStreamAbstractVisitorTestCase.php \org\bovigo\vfs\visitor\vfsStreamAbstractVisitorTestCase

Test for org\bovigo\vfs\visitor\vfsStreamAbstractVisitor.

@since 0.10.0 @group issue_10

Hierarchy

Expanded class hierarchy of vfsStreamAbstractVisitorTestCase

See also

https://github.com/mikey179/vfsStream/issues/10

File

vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/visitor/vfsStreamAbstractVisitorTestCase.php, line 21

Namespace

org\bovigo\vfs\visitor
View source
class vfsStreamAbstractVisitorTestCase extends \PHPUnit_Framework_TestCase {

  /**
   * instance to test
   *
   * @var  vfsStreamAbstractVisitor
   */
  protected $abstractVisitor;

  /**
   * set up test environment
   */
  public function setUp() {
    $this->abstractVisitor = $this
      ->getMock('org\\bovigo\\vfs\\visitor\\vfsStreamAbstractVisitor', array(
      'visitFile',
      'visitDirectory',
    ));
  }

  /**
   * @test
   * @expectedException  \InvalidArgumentException
   */
  public function visitThrowsInvalidArgumentExceptionOnUnknownContentType() {
    $mockContent = $this
      ->getMock('org\\bovigo\\vfs\\vfsStreamContent');
    $mockContent
      ->expects($this
      ->any())
      ->method('getType')
      ->will($this
      ->returnValue('invalid'));
    $this
      ->assertSame($this->abstractVisitor, $this->abstractVisitor
      ->visit($mockContent));
  }

  /**
   * @test
   */
  public function visitWithFileCallsVisitFile() {
    $file = new vfsStreamFile('foo.txt');
    $this->abstractVisitor
      ->expects($this
      ->once())
      ->method('visitFile')
      ->with($this
      ->equalTo($file));
    $this
      ->assertSame($this->abstractVisitor, $this->abstractVisitor
      ->visit($file));
  }

  /**
   * tests that a block device eventually calls out to visit file
   *
   * @test
   */
  public function visitWithBlockCallsVisitFile() {
    $block = new vfsStreamBlock('foo');
    $this->abstractVisitor
      ->expects($this
      ->once())
      ->method('visitFile')
      ->with($this
      ->equalTo($block));
    $this
      ->assertSame($this->abstractVisitor, $this->abstractVisitor
      ->visit($block));
  }

  /**
   * @test
   */
  public function visitWithDirectoryCallsVisitDirectory() {
    $dir = new vfsStreamDirectory('bar');
    $this->abstractVisitor
      ->expects($this
      ->once())
      ->method('visitDirectory')
      ->with($this
      ->equalTo($dir));
    $this
      ->assertSame($this->abstractVisitor, $this->abstractVisitor
      ->visit($dir));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
vfsStreamAbstractVisitorTestCase::$abstractVisitor protected property instance to test
vfsStreamAbstractVisitorTestCase::setUp public function set up test environment
vfsStreamAbstractVisitorTestCase::visitThrowsInvalidArgumentExceptionOnUnknownContentType public function @test @expectedException \InvalidArgumentException
vfsStreamAbstractVisitorTestCase::visitWithBlockCallsVisitFile public function tests that a block device eventually calls out to visit file
vfsStreamAbstractVisitorTestCase::visitWithDirectoryCallsVisitDirectory public function @test
vfsStreamAbstractVisitorTestCase::visitWithFileCallsVisitFile public function @test