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

Commit

Permalink
Merge branch 'master' into ValidatorMessages
Browse files Browse the repository at this point in the history
  • Loading branch information
Matej Szendi committed Nov 4, 2013
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 28 deletions.
3 changes: 3 additions & 0 deletions src/ClassFileLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ public function accept()
}
$class = (null === $namespace) ? $content : $namespace . '\\' . $content;
$file->addClass($class);
if ($namespace) {
$file->addNamespace($namespace);
}
$namespace = null;
break;
}
Expand Down
34 changes: 32 additions & 2 deletions src/PhpClassFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ class PhpClassFile extends SplFileInfo
/**
* @var array
*/
protected $classes;
protected $classes = array();

/**
* @var array
*/
protected $namespaces = array();

/**
* Get classes
Expand All @@ -31,15 +36,40 @@ public function getClasses()
return $this->classes;
}

/**
* Get namespaces
*
* @return array
*/
public function getNamespaces()
{
return $this->namespaces;
}

/**
* Add class
*
* @param string $class
* @return PhpClassFile
* @return self
*/
public function addClass($class)
{
$this->classes[] = $class;
return $this;
}

/**
* Add namespace
*
* @param string $namespace
* @return self
*/
public function addNamespace($namespace)
{
if (in_array($namespace, $this->namespaces)) {
return $this;
}
$this->namespaces[] = $namespace;
return $this;
}
}
13 changes: 9 additions & 4 deletions test/ClassFileLocatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_File
*/

namespace ZendTest\File;
Expand All @@ -15,9 +14,6 @@
/**
* Test class for Zend\File\ClassFileLocator
*
* @category Zend
* @package Zend_File
* @subpackage UnitTests
* @group Zend_File
*/
class ClassFileLocatorTest extends \PHPUnit_Framework_TestCase
Expand Down Expand Up @@ -83,6 +79,15 @@ public function testIterationShouldInjectNamespaceInFoundItems()
$this->assertTrue($found);
}

public function testIterationShouldInjectNamespacesInFileInfo()
{
$locator = new ClassFileLocator(__DIR__);
foreach ($locator as $file) {
$namespaces = $file->getNamespaces();
$this->assertTrue(count($namespaces) > 0);
}
}

public function testIterationShouldInjectClassInFoundItems()
{
$locator = new ClassFileLocator(__DIR__);
Expand Down
5 changes: 0 additions & 5 deletions test/TestAsset/LocatorShouldFindThis.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_File
*/

namespace ZendTest\File\TestAsset;

/**
* @package Zend_Loader
* @subpackage Exception
*/
interface LocatorShouldFindThis
{
}
1 change: 0 additions & 1 deletion test/TestAsset/MultipleClassesInMultipleNamespaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_File
*/

namespace ZendTest\File\TestAsset
Expand Down
4 changes: 0 additions & 4 deletions test/Transfer/Adapter/AbstractAdapterTestMockAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_File
*/

namespace ZendTest\File\Transfer\Adapter;
Expand All @@ -15,9 +14,6 @@
/**
* Test class for Zend\File\Transfer\Adapter\AbstractAdapter
*
* @category Zend
* @package Zend_File
* @subpackage UnitTests
* @group Zend_File
*/
class AbstractAdapterTestMockAdapter extends Adapter\AbstractAdapter
Expand Down
4 changes: 0 additions & 4 deletions test/Transfer/Adapter/AbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_File
*/

namespace ZendTest\File\Transfer\Adapter;
Expand All @@ -20,9 +19,6 @@
/**
* Test class for Zend\File\Transfer\Adapter\AbstractAdapter
*
* @category Zend
* @package Zend_File
* @subpackage UnitTests
* @group Zend_File
*/
class AbstractTest extends \PHPUnit_Framework_TestCase
Expand Down
4 changes: 0 additions & 4 deletions test/Transfer/Adapter/HttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_File
*/

namespace ZendTest\File\Transfer\Adapter;
Expand All @@ -19,9 +18,6 @@
/**
* Test class for Zend\File\Transfer\Adapter\Http
*
* @category Zend
* @package Zend_File
* @subpackage UnitTests
* @group Zend_File
*/
class HttpTest extends \PHPUnit_Framework_TestCase
Expand Down
4 changes: 0 additions & 4 deletions test/Transfer/Adapter/HttpTestMockAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_File
*/

namespace ZendTest\File\Transfer\Adapter;
Expand All @@ -15,9 +14,6 @@
/**
* Test class for Zend\File\Transfer\Adapter\AbstractAdapter
*
* @category Zend
* @package Zend_File
* @subpackage UnitTests
* @group Zend_File
*/
class HttpTestMockAdapter extends Adapter\Http
Expand Down

0 comments on commit b49dbbb

Please sign in to comment.