Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/TagsWithSameValueTest.php not adressing the problem #14

Open
Maturion opened this issue Mar 1, 2017 · 1 comment
Open

tests/TagsWithSameValueTest.php not adressing the problem #14

Maturion opened this issue Mar 1, 2017 · 1 comment

Comments

@Maturion
Copy link

Maturion commented Mar 1, 2017

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.

@Maturion Maturion changed the title TagsWithSameValueTest.php not adressing the problem tests/TagsWithSameValueTest.php not adressing the problem Mar 1, 2017
Maturion added a commit to Maturion/Services_Openstreetmap that referenced this issue Mar 1, 2017
The following change would remove the check that's preventing two tags from having the same value (as described at pear#14 )
@kenguest
Copy link
Member

kenguest commented Mar 6, 2017

No offence taken - please do provide a test/example that does demonstrate the problem conclusively though!

kenguest added a commit that referenced this issue Mar 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants