[FLOW3-general] Phpunit: Mocking persistence/ aspects
Sebastian Kurfürst
sebastian at typo3.org
Tue Oct 26 06:26:30 CEST 2010
Hey Martin,
Am 25.10.10 18:07, schrieb Martin Eisengardt:
> Another question :-)
>
> First let me explain what I am doing. I played around creating some kind of transactional support. Some kind of transactional entities should be able to persist their changes in database and later on commit or resume them to the trunk object state. That may be useful to have transaction management spread over multiple requests.
I think you should use @scope session for that. Example:
Let's say I want to make a Blog Post "Transactional", i.e. want to
update it during multiple requests, but update the changes in the
database atomically.
Then, I create a new PostSessionStoreService, which is marked @scope
session -- meaning that this object and all attached objects will be
automatically stored in the user's session. To you, it looks as if you
will get the same object in all requests.
Then, when you want to "commit" your changes, you remove the blog post
from the PostSessionStoreService, and add it to the database via
$repository->add(...) or ->update(...).
Does that make sense? :-)
> For now I am looking for a way to write the unit tests. The test case will have to verify that changes are persisted in database. After creating an entity the persistence will be forced to persist all (thats all about the first request would be doing). Then the entity is queried from persistence (At this point the second request would be starting) and I will do some assertions. Because the transactional stuff is implemented by aspects I would need a full working ObjectManager that does the aop stuff on the entity. I will need a full working backend (or some mocked backend). I will need a possibility to invoke persistAll.
To me, this sounds more like Functional Tests, what you mean. Robert has
just spent the last days to implement that; it has landed in trunk
yesterday, and I think can be soon used.
Greets,
Sebastian
More information about the FLOW3-general
mailing list