Permalink
Browse files

Tested: Some more uncovered parts in PHP_Depend_Code

  • Loading branch information...
1 parent 4934828 commit c2d2557084a7ae4c7240ec0846d9c10d47a24395 @manuelpichler committed Feb 3, 2012
@@ -47,6 +47,8 @@
* @since 0.9.6
*/
+// @codeCoverageIgnoreStart
+
/**
* Root interface for an ast node.
*
@@ -195,3 +197,5 @@ function accept(PHP_Depend_Code_ASTVisitorI $visitor, $data = null);
*/
function free();
}
+
+// @codeCoverageIgnoreStart
@@ -66,8 +66,8 @@ class PHP_Depend_Code_ClassOrInterfaceReferenceIterator
/**
* Constructs a new reference iterator instance.
*
- * @param array(PHP_Depend_Code_ASTClassOrInterfaceReference) $references List
- * of references to concrete type instances.
+ * @param PHP_Depend_Code_ASTClassOrInterfaceReference[] $references List of
+ * references to concrete type instances.
*/
public function __construct(array $references)
{
@@ -78,10 +78,10 @@ public function __construct(array $references)
* This method creates a set of {@link PHP_Depend_Code_AbstractClassOrInterface}
* objects from the given reference array.
*
- * @param array(PHP_Depend_Code_ASTClassOrInterfaceReference) $references List
- * of references to concrete type instances.
+ * @param PHP_Depend_Code_ASTClassOrInterfaceReference[] $references List of
+ * references to concrete type instances.
*
- * @return array(PHP_Depend_Code_AbstractClassOrInterface)
+ * @return PHP_Depend_Code_AbstractClassOrInterface[]
*/
protected function createClassesAndInterfaces(array $references)
{
@@ -46,6 +46,8 @@
* @link http://pdepend.org/
*/
+// @codeCoverageIgnoreStart
+
/**
* Represents any possible code node.
*
@@ -84,3 +86,5 @@ function getUUID();
*/
function accept(PHP_Depend_VisitorI $visitor);
}
+
+// @codeCoverageIgnoreEnd
@@ -1881,6 +1881,20 @@ public function testBuildASTMemberPrimaryPrefixReturnsExpectedType()
}
/**
+ * testBuildASTMethodPostfixReturnsExpectedType
+ *
+ * @return void
+ * @since 1.0.0
+ */
+ public function testBuildASTMethodPostfixReturnsExpectedType()
+ {
+ $this->assertInstanceOf(
+ PHP_Depend_Code_ASTMethodPostfix::CLAZZ,
+ $this->createBuilder()->buildASTMethodPostfix('foo')
+ );
+ }
+
+ /**
* testBuildASTFunctionPostfixReturnsExpectedType
*
* @return void
@@ -63,6 +63,7 @@
* @since 1.0.0
*
* @covers PHP_Depend_Parser
+ * @covers PHP_Depend_Code_ASTNode
* @covers PHP_Depend_Code_ASTArrayElement
* @group pdepend
* @group pdepend::ast
@@ -61,6 +61,7 @@
* @link http://www.pdepend.org/
*
* @covers PHP_Depend_Parser
+ * @covers PHP_Depend_Code_ASTIndexExpression
* @covers PHP_Depend_Code_ASTArrayIndexExpression
* @group pdepend
* @group pdepend::ast
@@ -61,6 +61,7 @@
* @link http://www.pdepend.org/
*
* @covers PHP_Depend_Parser
+ * @covers PHP_Depend_Code_ASTNode
* @covers PHP_Depend_Code_ASTClosure
* @group pdepend
* @group pdepend::ast
@@ -61,6 +61,7 @@
* @link http://www.pdepend.org/
*
* @covers PHP_Depend_Parser
+ * @covers PHP_Depend_Code_ASTNode
* @covers PHP_Depend_Code_ASTFormalParameter
* @group pdepend
* @group pdepend::ast
@@ -61,6 +61,7 @@
* @link http://www.pdepend.org/
*
* @covers PHP_Depend_Parser
+ * @covers PHP_Depend_Code_ASTInvocation
* @covers PHP_Depend_Code_ASTFunctionPostfix
* @group pdepend
* @group pdepend::ast
@@ -61,7 +61,7 @@
* @link http://www.pdepend.org/
*
* @covers PHP_Depend_Parser
- * @covers PHP_Depend_Builder_Default
+ * @covers PHP_Depend_Code_ASTInvocation
* @covers PHP_Depend_Code_ASTMethodPostfix
* @group pdepend
* @group pdepend::ast
@@ -63,6 +63,7 @@
* @since 0.9.12
*
* @covers PHP_Depend_Parser
+ * @covers PHP_Depend_Code_ASTIndexExpression
* @covers PHP_Depend_Code_ASTStringIndexExpression
* @group pdepend
* @group pdepend::ast
@@ -0,0 +1,146 @@
+<?php
+/**
+ * This file is part of PHP_Depend.
+ *
+ * PHP Version 5
+ *
+ * Copyright (c) 2008-2012, Manuel Pichler <mapi@pdepend.org>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Manuel Pichler nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category QualityAssurance
+ * @package PHP_Depend
+ * @author Manuel Pichler <mapi@pdepend.org>
+ * @copyright 2008-2012 Manuel Pichler. All rights reserved.
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id$
+ * @link http://pdepend.org/
+ * @since 1.0.0
+ */
+
+require_once dirname(__FILE__) . '/../AbstractTest.php';
+
+/**
+ * Test case for the {@link PHP_Depend_Code_ClassOrInterfaceReferenceIterator}
+ * class.
+ *
+ * @category QualityAssurance
+ * @package PHP_Depend
+ * @author Manuel Pichler <mapi@pdepend.org>
+ * @copyright 2008-2012 Manuel Pichler. All rights reserved.
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: @package_version@
+ * @link http://pdepend.org/
+ * @since 1.0.0
+ *
+ * @covers PHP_Depend_Code_ClassOrInterfaceReferenceIterator
+ * @group pdepend
+ * @group pdepend::code
+ * @group unittest
+ */
+class PHP_Depend_Code_ClassOrInterfaceReferenceIteratorTest extends PHP_Depend_AbstractTest
+{
+ /**
+ * testIteratorReturnsExpectedClasses
+ *
+ * @return void
+ */
+ public function testIteratorReturnsExpectedClasses()
+ {
+ $class1 = new PHP_Depend_Code_Class('c1');
+ $class1->setUUID(md5(23));
+
+ $class2 = new PHP_Depend_Code_Class('c2');
+ $class2->setUUID(md5(42));
+
+ $reference1 = $this->getMockBuilder(PHP_Depend_Code_ASTSelfReference::CLAZZ)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $reference1->expects($this->once())
+ ->method('getType')
+ ->will($this->returnValue($class1));
+
+ $reference2 = $this->getMockBuilder(PHP_Depend_Code_ASTSelfReference::CLAZZ)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $reference2->expects($this->once())
+ ->method('getType')
+ ->will($this->returnValue($class2));
+
+ $references = array($reference1, $reference2);
+
+ $refs = new PHP_Depend_Code_ClassOrInterfaceReferenceIterator($references);
+ $types = array();
+ foreach ($refs as $type) {
+ $types[] = $type->getUUID();
+ }
+
+ $this->assertEquals(array($class1->getUUID(), $class2->getUUID()), $types);
+ }
+
+ /**
+ * testIteratorReturnsSameClassOnlyOnce
+ *
+ * @return void
+ */
+ public function testIteratorReturnsSameClassOnlyOnce()
+ {
+ $class1 = new PHP_Depend_Code_Class('c1');
+ $class1->setUUID(md5(23));
+
+ $class2 = new PHP_Depend_Code_Class('c2');
+ $class2->setUUID(md5(23));
+
+ $reference1 = $this->getMockBuilder(PHP_Depend_Code_ASTSelfReference::CLAZZ)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $reference1->expects($this->once())
+ ->method('getType')
+ ->will($this->returnValue($class1));
+
+ $reference2 = $this->getMockBuilder(PHP_Depend_Code_ASTSelfReference::CLAZZ)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $reference2->expects($this->once())
+ ->method('getType')
+ ->will($this->returnValue($class2));
+
+ $references = array($reference1, $reference2);
+
+ $refs = new PHP_Depend_Code_ClassOrInterfaceReferenceIterator($references);
+ $types = array();
+ foreach ($refs as $type) {
+ $types[] = $type->getUUID();
+ }
+
+ $this->assertEquals(array($class1->getUUID()), $types);
+ }
+}
@@ -1408,6 +1408,7 @@ public function testGetParentClassReturnsExpectedClassInstance()
* testGetParentClassThrowsExpectedExceptionWhenBothAreTheSame
*
* @return void
+ * @covers PHP_Depend_Code_Exceptions_AbstractException
* @covers PHP_Depend_Code_Exceptions_RecursiveInheritanceException
* @expectedException PHP_Depend_Code_Exceptions_RecursiveInheritanceException
*/
@@ -1478,6 +1479,7 @@ public function testGetParentReturnsNullWhenParentIsFiltered()
* testGetParentClassesThrowsExpectedExceptionForRecursiveInheritanceHierarchy
*
* @return void
+ * @covers PHP_Depend_Code_Exceptions_AbstractException
* @covers PHP_Depend_Code_Exceptions_RecursiveInheritanceException
* @expectedException PHP_Depend_Code_Exceptions_RecursiveInheritanceException
*/
@@ -320,6 +320,8 @@ public function testGetStaticVariablesReturnsMergeOfAllStaticVariables()
* testGetSourceFileThrowsExpectedExceptionWhenNoParentWasDefined
*
* @return void
+ * @covers PHP_Depend_Code_Exceptions_AbstractException
+ * @covers PHP_Depend_Code_Exceptions_SourceNotFoundException
* @expectedException PHP_Depend_Code_Exceptions_SourceNotFoundException
*/
public function testGetSourceFileThrowsExpectedExceptionWhenNoParentWasDefined()
@@ -67,6 +67,18 @@
class PHP_Depend_Code_PackageTest extends PHP_Depend_AbstractTest
{
/**
+ * testGetUUIDReturnsExpectedObjectHash
+ *
+ * @return void
+ * @since 1.0.0
+ */
+ public function testGetUUIDReturnsExpectedObjectHash()
+ {
+ $package = new PHP_Depend_Code_Package(__FUNCTION__);
+ $this->assertEquals(spl_object_hash($package), $package->getUUID());
+ }
+
+ /**
* Tests that the {@link PHP_Depend_Code_Package::getTypes()} method returns
* an empty {@link PHP_Depend_Code_NodeIterator}.
*
Oops, something went wrong.

0 comments on commit c2d2557

Please sign in to comment.