Skip to content

Commit

Permalink
Merge pull request #6 from mateu-aguilo-bosch/pathfinder-tests
Browse files Browse the repository at this point in the history
PathFinderBase tests
  • Loading branch information
e0ipso committed Jun 15, 2015
2 parents 1b3a1f4 + 4e84bf1 commit 0140347
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tests/src/Discovery/PathFinderBaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,32 @@
*/
class PathFinderBaseTest extends \PHPUnit_Framework_TestCase {

/**
* Tests that constructor works properly.
*
* @covers ::__construct()
*/

public function testConstructor() {
$pathFinder = new FakePathFinder(['./testFolder/']);
$property = new \ReflectionProperty($pathFinder, 'path');
$property->setAccessible(true);
$value = $property->getValue($pathFinder);
$this->assertEquals('./testFolder/', $value);
}

/**
* Tests that PathFinderBase::requireFile() works properly.
*
* @covers ::requireFile()
*/
public function testRequireFile() {
$pathFinder = new FakePathFinder(['']);
$pathFinder->requireFile(realpath('data/acme.inc'));
$included = get_included_files();
$this->assertTrue(in_array(realpath('data/acme.inc'), $included));
}

/**
* Tests that PathFinderBase::cleanDirPath() works properly.
* @dataProvider cleanDirPathProvider
Expand Down Expand Up @@ -49,7 +75,7 @@ public function cleanDirPathProvider()
class FakePathFinder extends PathFinderBase {

public function find($seed) {

return realpath($seed);
}

}
41 changes: 41 additions & 0 deletions tests/src/Discovery/PathFinderContribTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/**
* @file
* Contains Drupal\Composer\ClassLoader\Discovery\PathFinderContribTest.
*/

namespace Drupal\Composer\ClassLoader\Discovery\Tests;

use Drupal\Composer\ClassLoader\Discovery\PathFinderContrib;

/**
* Class PathFinderContribTest
* @coversDefaultClass \Drupal\Composer\ClassLoader\Discovery\PathFinderContrib
* @package Drupal\Composer\ClassLoader\Discovery\Tests
*/
class PathFinderContribTest extends \PHPUnit_Framework_TestCase {

/**
* Tests that constructor works properly.
*
* @covers ::__construct()
*/
public function testConstructor() {
$pathFinder = new PathFinderContrib(['./testFolder/', 'mymodule']);

// Assert path is set.
$property = new \ReflectionProperty($pathFinder, 'path');
$property->setAccessible(true);
$value = $property->getValue($pathFinder);
$this->assertEquals('./testFolder/', $value);

// Assert module name is set.
$property = new \ReflectionProperty($pathFinder, 'moduleName');
$property->setAccessible(true);
$value = $property->getValue($pathFinder);
$this->assertEquals('mymodule', $value);
}

}

0 comments on commit 0140347

Please sign in to comment.