Permalink
Browse files

Fixes #1095 - check for UnknownElement

  • Loading branch information...
1 parent 87aa987 commit fb5d51bddb2123e3cb5500232771496206848d47 @mrook mrook committed Jul 18, 2014
View
2 classes/phing/tasks/system/condition/ReferenceExistsCondition.php
@@ -46,7 +46,7 @@ public function evaluate() {
. "condition");
}
$refs = $this->project->getReferences();
- return isset($refs[$this->refid]);
+ return ! ($refs[$this->refid] instanceof UnknownElement) && isset($refs[$this->refid]);
}
}
View
6 test/classes/phing/tasks/system/ConditionTaskTest.php
@@ -39,5 +39,11 @@ public function testCustomCondition()
$this->executeTarget(__FUNCTION__);
$this->assertPropertySet('isCustom');
}*/
+
+ public function testReferenceExists()
+ {
+ $this->executeTarget(__FUNCTION__);
+ $this->assertPropertyUnset('ref.exists');
+ }
}
View
10 test/etc/tasks/system/ConditionTest.xml
@@ -18,4 +18,14 @@
<testcondition foo="bar"/>
</condition>
</target>
+
+ <target name="testReferenceExists">
+ <condition property="ref.exists">
+ <referenceexists ref="file.set"/>
+ </condition>
+ <echo>${ref.exists}</echo>
+ <patternset id="file.set">
+ <include name="build.xml"/>
+ </patternset>
+ </target>
</project>

0 comments on commit fb5d51b

Please sign in to comment.