Unit testing an object state change across multiple classes in PHP -



Unit testing an object state change across multiple classes in PHP -

scenario: have value object beingness passed, reference, around several objects (in case event listeners) , state modified in 1 of objects. after event listeners triggered there phone call saves object info store new state. has been fixed making event listener not work straight value object.

question: how can write regression unit test check value object not modified @ time save happens?

example:

public function somecontrolleraction() { $value = new \stdclass(); $value->property = 'awesome'; $value->type = 'test'; $obj->method($value); $otherobj-> methodchangesstatebutshouldnot($value); // if method bad alter state of value // value needs same state when created $db->save($value); }

if mean methodchangesstatebutshouldnot() don't think should test here. if $otherobj not supposed alter $value test in other object::method has create sure input , output same. testing here mean create real instance of $otherobj instead of false , maybe whole lot more of context , that's not point of unit testing, it.

if $otherobj::methodchangesstate static method maybe dare it. clone $value , assert $value before , after equal.

php unit-testing pass-by-reference

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -