Skip to content

Test if getHash is static - #132

Closed
thiemowmde wants to merge 1 commit into
masterfrom
selfcompare
Closed

Test if getHash is static#132
thiemowmde wants to merge 1 commit into
masterfrom
selfcompare

Conversation

@thiemowmde

Copy link
Copy Markdown
Contributor

This should fix #130.

It turns out PHP's serialize() function just calls the ...->serialize() methods provided by the Serializable interface in Snak. See the implementations in SnakObject::serialize and PropertyValueSnak::serialize. Only properties that are used in these methods become part of the serialization.

This patch:

  • Adds tests to make sure the getHash implementation is static and doesn't change, e.g. when new fields are introduced.
  • Adds basic tests for No- and SomeValueSnak.
  • Removes strange self-comparisons from tests.
  • Simplifies some loops.
  • Renames some strange variables.

Comment thread tests/unit/Snak/SnakObjectTest.php Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!

@thiemowmde thiemowmde changed the title Remove self-comparisons from tests Test if getHash is static Aug 4, 2014
This was referenced Aug 13, 2014
@JeroenDeDauw

Copy link
Copy Markdown
Contributor

@thiemowmde sad kittens are sad

@thiemowmde

Copy link
Copy Markdown
Contributor Author

Never got an answer to my last question. Seems it's fine to break all our hashing from time to time.

If you ask me it's not better if all hashes break because we reimplement the hash function or if they break because of a namespace change. The later is much more unlikely at this point in time. Coming up with a new hash function will break everything for sure. Just keeping the hash functions as they are will not break anything. Therefor I'm closing this now.

@thiemowmde thiemowmde closed this Oct 14, 2014
@JeroenDeDauw
JeroenDeDauw deleted the selfcompare branch October 14, 2014 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Snak hash should be stable and PHP independent

2 participants