Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
s/Locater/Locator/gs
Browse files Browse the repository at this point in the history
- Fixed all instances where class/interface names used "Locater" to "Locator",
  and attempted to ensure tests would run when possible (in some cases, tests
  were failing before)
  • Loading branch information
weierophinney committed Apr 14, 2011
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/ClassFileLocater.php → src/ClassFileLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
* @package Zend_File
* @license New BSD {@link http://framework.zend.com/license/new-bsd}
*/
class ClassFileLocater extends FilterIterator
class ClassFileLocator extends FilterIterator
{
/**
* Create an instance of the locater iterator
* Create an instance of the locator iterator
*
* Expects either a directory, or a DirectoryIterator (or its recursive variant)
* instance.
Expand Down
8 changes: 4 additions & 4 deletions src/Transfer/Adapter/AbstractAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
Zend\File\Transfer\Exception,
Zend\Loader\PrefixPathLoader,
Zend\Loader\PrefixPathMapper,
Zend\Loader\ShortNameLocater,
Zend\Loader\ShortNameLocator,
Zend\Validator,
Zend\Filter;

Expand Down Expand Up @@ -223,12 +223,12 @@ abstract public function isFiltered($files = null);
/**
* Set plugin loader to use for validator or filter chain
*
* @param \Zend\Loader\PrefixPathMapper $loader
* @param \Zend\Loader\ShortNameLocator $loader
* @param string $type 'filter', or 'validator'
* @return \Zend\File\Transfer\Adapter\AbstractAdapter
* @throws \Zend\File\Transfer\Exception on invalid type
*/
public function setPluginLoader(ShortNameLocater $loader, $type)
public function setPluginLoader(ShortNameLocator $loader, $type)
{
$type = strtoupper($type);
switch ($type) {
Expand All @@ -248,7 +248,7 @@ public function setPluginLoader(ShortNameLocater $loader, $type)
* 'filter' or 'validator' for $type.
*
* @param string $type
* @return \Zend\Loader\ShortNameLocater
* @return \Zend\Loader\ShortNameLocator
* @throws \Zend\File\Transfer\Exception on invalid type.
*/
public function getPluginLoader($type)
Expand Down
37 changes: 19 additions & 18 deletions test/ClassFileLocater.php → test/ClassFileLocatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@

namespace ZendTest\File;

use Zend\File\ClassFileLocater;
use Zend\File\ClassFileLocator,
PHPUnit_Framework_TestCase as TestCase;

/**
* Test class for Zend\File\ClassFileLocater
* Test class for Zend\File\ClassFileLocator
*
* @category Zend
* @package Zend_File
Expand All @@ -33,36 +34,36 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
* @group Zend_File
*/
class ClassFileLocaterTest extends \PHPUnit_Framework_TestCase
class ClassFileLocatorTest extends TestCase
{

public function testConstructorThrowsInvalidArgumentExceptionForInvalidStringDirectory()
{
$this->setExpectedException('Zend\File\Exception\InvalidArgumentException');
$locater = new ClassFileLocater('__foo__');
$locator = new ClassFileLocator('__foo__');
}

public function testConstructorThrowsInvalidArgumentExceptionForNonDirectoryIteratorArgument()
{
$iterator = new \ArrayIterator(array());
$this->setExpectedException('Zend\File\Exception\InvalidArgumentException');
$locater = new ClassFileLocater($iterator);
$locator = new ClassFileLocator($iterator);
}

public function testIterationShouldReturnOnlyPhpFiles()
{
$locater = new ClassFileLocater(__DIR__);
foreach ($locater as $file) {
$locator = new ClassFileLocator(__DIR__);
foreach ($locator as $file) {
$this->assertRegexp('/\.php$/', $file->getFilename());
}
}

public function testIterationShouldReturnOnlyPhpFilesContainingClasses()
{
$locater = new ClassFileLocater(__DIR__);
$locator = new ClassFileLocator(__DIR__);
$found = false;
foreach ($locater as $file) {
if (preg_match('/locater-should-skip-this\.php$/', $file->getFilename())) {
foreach ($locator as $file) {
if (preg_match('/locator-should-skip-this\.php$/', $file->getFilename())) {
$found = true;
}
}
Expand All @@ -71,30 +72,30 @@ public function testIterationShouldReturnOnlyPhpFilesContainingClasses()

public function testIterationShouldReturnInterfaces()
{
$locater = new ClassFileLocater(__DIR__);
$locator = new ClassFileLocator(__DIR__);
$found = false;
foreach ($locater as $file) {
if (preg_match('/LocaterShouldFindThis\.php$/', $file->getFilename())) {
foreach ($locator as $file) {
if (preg_match('/LocatorShouldFindThis\.php$/', $file->getFilename())) {
$found = true;
}
}
$this->assertTrue($found, "Locater skipped an interface?");
$this->assertTrue($found, "Locator skipped an interface?");
}

public function testIterationShouldInjectNamespaceInFoundItems()
{
$locater = new ClassFileLocater(__DIR__);
$locator = new ClassFileLocator(__DIR__);
$found = false;
foreach ($locater as $file) {
foreach ($locator as $file) {
$this->assertTrue(isset($file->namespace));
}
}

public function testIterationShouldInjectClassInFoundItems()
{
$locater = new ClassFileLocater(__DIR__);
$locator = new ClassFileLocator(__DIR__);
$found = false;
foreach ($locater as $file) {
foreach ($locator as $file) {
$this->assertTrue(isset($file->classname));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface LocaterShouldFindThis
interface LocatorShouldFindThis
{
}
4 changes: 2 additions & 2 deletions test/Transfer/Adapter/AbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
namespace ZendTest\File\Transfer\Adapter;

use Zend\Loader\PrefixPathLoader,
Zend\Loader\ShortNameLocater,
Zend\Loader\ShortNameLocator,
Zend\Validator\File,
Zend\Filter,
Zend\File\Transfer;
Expand Down Expand Up @@ -339,7 +339,7 @@ public function testErrorCodesShouldBePopulatedAfterInvalidTransfer()
public function testAdapterShouldHavePluginLoaderForFilters()
{
$loader = $this->adapter->getPluginLoader('filter');
$this->assertTrue($loader instanceof ShortNameLocater);
$this->assertTrue($loader instanceof ShortNameLocator);
}

public function testFilterPluginLoaderShouldRegisterPathsForBaseAndFileFiltersByDefault()
Expand Down
2 changes: 0 additions & 2 deletions test/_files/locater-should-skip-this.php

This file was deleted.

2 changes: 2 additions & 0 deletions test/_files/locator-should-skip-this.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
// Locator should skip this file; no classes in it

0 comments on commit 5b3198f

Please sign in to comment.