code_junkie

Unit testing Doctrine objects with PHPUnit

Nov 12th, 2011
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. class Tests_User extends PHPUnit_Framework_TestCase
  2. {
  3.  
  4. public function setUp()
  5. {
  6.  
  7. Doctrine_Manager::connection('mysql://user:pass@localhost/testdb');
  8.  
  9. Doctrine::createDatabases();
  10. Doctrine::createTablesFromModels('../../application/models');
  11.  
  12. }
  13.  
  14. public function testSavingWorks()
  15. {
  16.  
  17. $user = new User();
  18. $user->save();
  19.  
  20. }
  21.  
  22. public function testSavingWorksAgain()
  23. {
  24.  
  25. $user = new User();
  26. $user->save();
  27.  
  28. }
  29.  
  30. public function tearDown()
  31. {
  32.  
  33. Doctrine::dropDatabases();
  34.  
  35. }
  36.  
  37. }
  38.  
  39. Doctrine::loadModels($path);
  40. Doctrine::createTablesFromArray(Doctrine::getLoadedModels());
Add Comment
Please, Sign In to add comment