You can check https://gist.github.com/Ocramius/3994325
Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On 16 April 2013 13:20, Katalin [via Zend Framework Community] < [email protected]> wrote: > Hi! > Not a long time ago i found out about mock objects. Would be great if I > could implement them too. The code I came up with untill now (which > obviously fails) is: > <nabble_embed> <?php namespace BlogTest\Service; class BlogTest extends > \PHPUnit_Framework_TestCase { private $mock = null; public function setUp() > { //'Doctrine\ORM\EntityManager' ? $this->mock = > $this->getMock("Blog\Entity\Post", array('persist', 'flush')); } public > function testCanInsertBlogEntry() { $this->mock->user_id = 1; > $this->mock->cat_id = 1; $this->mock->title = "lol"; $this->mock->adress = > "lol"; $this->mock->post_date = new \DateTime('now'); > $this->mock->allow_comments = true; > $this->assertEquals($this->mock->persist(), true); } public function > testBlogPostEntityShouldExist() { } }</nabble_embed> > > The "Blog\Entity\Post" is loaded correctly, but I don't have the persist > method into it. So, how do I save it somewhere to simulate a real database? > I would like to access some methods who create a new record with say a > param "name" set to "x", and then test if it was created successfully by > finding the "name" => "x". Should I retrieve the mock > 'Doctrine\ORM\EntityManager' ? > Really appreciate. > Great tut, btw. http://marco-pivetta.com/doctrine-orm-zf2-tutorial/ > > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > > http://zend-framework-community.634137.n4.nabble.com/Doctrine-zf2-tests-Marco-Pivetta-tp4659730.html > To start a new topic under Zend Framework, email > [email protected] > To unsubscribe from Zend Framework Community, click > here<http://zend-framework-community.634137.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=634137&code=b2NyYW1pdXNAZ21haWwuY29tfDYzNDEzN3wxNzE0OTI1MTk4> > . > NAML<http://zend-framework-community.634137.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/Re-Doctrine-zf2-tests-Marco-Pivetta-tp4659731.html Sent from the Zend Framework mailing list archive at Nabble.com.
