You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While building up our unit testing coverage I came upon a situation where I'd very much like to mock a handful of small methods we have in our data objects. These are just things akin to isEnabled() that are based on the immutable data within the object but might reference information that's buried within complex data structures with various complexities of business logic to determine -- data structures and business logic we really don't want to have to deal with in every unit test.
Is there some trick to having Mockery extend a Data class or some other way to emulate the behavior without Mockery? I've traversed a ways into the laravel-data code to look for opportunities but it looks very stringently reliant on starting with static::class and my attempts to extend Data to add greater intelligence into the from() method either isn't enough or just not workable; I can seemingly get laravel-data at least partially using Mockery's extension but it seems incomplete (getting errors that the __construct() method has no expectations set).
Any thoughts or direction for this would be appreciated.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
While building up our unit testing coverage I came upon a situation where I'd very much like to mock a handful of small methods we have in our data objects. These are just things akin to
isEnabled()
that are based on the immutable data within the object but might reference information that's buried within complex data structures with various complexities of business logic to determine -- data structures and business logic we really don't want to have to deal with in every unit test.Is there some trick to having Mockery extend a Data class or some other way to emulate the behavior without Mockery? I've traversed a ways into the
laravel-data
code to look for opportunities but it looks very stringently reliant on starting withstatic::class
and my attempts to extendData
to add greater intelligence into thefrom()
method either isn't enough or just not workable; I can seemingly getlaravel-data
at least partially using Mockery's extension but it seems incomplete (getting errors that the__construct()
method has no expectations set).Any thoughts or direction for this would be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions