Ticket #383 (closed defect: fixed)
IfTask boolean issues with predefined properties
| Reported by: | saloon12yrd@… | Owned by: | mp |
|---|---|---|---|
| Priority: | major | Milestone: | 2.5.0 |
| Component: | phing-core | Version: | 2.3.3 |
| Keywords: | properties, PhpUnitTask, boolean, ifTask | Cc: | Mp@… |
Description
Hi all,
I discovered an anomaly in the IfTask in combination with the failureproperty of the PhpUnittestTask.
The environment is Phing 2.3.3 with PHPUnit 3.3.17 on Ubuntu 9.10 using bash.
If you initialize the property used as failureproperty in the PhpUnittestTask through a PropertyTask first, the IfTask does no longer work as expected. I attached three example build scripts to clarify this, but in a nutshell it is like this:
Assuming
<phpunit failureproperty="unittestFailed">
and
<if>
<equals arg1="${unittestFailed}" arg2="1" /> <then>
we have the following behaviour:
- without initializing the unittestFailed property the if condition works as expected
- with <property name="unittestFailed" value="false" /> the if condition will always enter the else-branch, regardless of the state of the unittests.
- with <property name="unittestFailed" value="true" /> the if condition will always enter the then-branch, regardless of the state of the unittests.
This is not really a bug in my opinion, more a unclean behaviour. If might lead to incorrect behaviour however, if one and the same property (in this case unittestFailed) is used as common status flag for multiple tests which all have to go through.
Regards, Dominique
Attachments
Change History
comment:1 Changed 2 years ago by mrook
- Keywords properties, added
- Priority changed from minor to major
- Milestone changed from 2.4.0RC3 to 3.0
You are completely right - the ambiguity lies in the distinction between user and system properties, something we need to look at properly. Therefore I'm moving this to the 3.0 branch for now. Thanks for the report!
comment:2 Changed 8 months ago by mp
Without having run the examples provided >:-) I'd guess the problem is that the task calls setNewProperty:
324 $this->project->setNewProperty($this->failureproperty, true);
that should just be setProperty().
Of course it still fails if you set that property on the command line. Don't think that is an issue.

