Services_Openstreetmap
Services_Openstreetmap copied to clipboard
tests/TagsWithSameValueTest.php not adressing the problem
Sorry if the title of this issue sounds a bit harsh. I'm not a native English speaker, so no offense intended. ;)
I have recently submitted issue #12 and you created the TagsWithSameValueTest.php test class for verifying that. I can indeed confirm that my original issue does not occur in this test class.
Puzzled by this, I tried around a bit and found out that my original problem does not occur when creating a new node (This is what's being done in TagsWithSameValueTest.php). It only happens when you are editing an existing node.
The cause of this behaviour is the following:
array_diff($this->getTags(), $set) does compare $this->getTags() and $set.
Values are assigned to $set this way:
$set = array();
for ($i = 0; $i < $tags->length; $i++) {
$key = $tags->item($i)->getAttribute('k');
$val = $tags->item($i)->getAttribute('v');
$set[$key] = $val;
}
$set contains the values of an object before your new ChangeSet is applied. Hence when you create a new object, $set is empty and array_diff($this->getTags(), $set) will save two tags with the same value. However, when you're editing an existing object, $set is not empty, and the output of array_diff will indeed not contain two tags with the same value.
I didn't submit a pull request because I'm not sure wether this problem can be replicated without changing "real" data on the OSM database.
No offence taken - please do provide a test/example that does demonstrate the problem conclusively though!