SimpleTesterTest.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Test
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. require_once "Zend/Test/PHPUnit/Db/SimpleTester.php";
  23. require_once "Zend/Test/PHPUnit/Db/Connection.php";
  24. require_once "Zend/Test/DbAdapter.php";
  25. require_once "PHPUnit/Extensions/Database/DataSet/IDataSet.php";
  26. require_once "Zend/Test/PHPUnit/Db/Exception.php";
  27. /**
  28. * @category Zend
  29. * @package Zend_Test
  30. * @subpackage UnitTests
  31. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  32. * @license http://framework.zend.com/license/new-bsd New BSD License
  33. * @group Zend_Test
  34. */
  35. class Zend_Test_PHPUnit_Db_SimpleTesterTest extends PHPUnit_Framework_TestCase
  36. {
  37. public function testGetConnection()
  38. {
  39. $testAdapter = $this->getMock('Zend_Test_DbAdapter');
  40. $testAdapter->expects($this->any())
  41. ->method('delete')
  42. ->will($this->throwException(new Exception));
  43. $connection = new Zend_Test_PHPUnit_Db_Connection($testAdapter, "schema");
  44. $databaseTester = new Zend_Test_PHPUnit_Db_SimpleTester($connection);
  45. $this->assertSame($connection, $databaseTester->getConnection());
  46. }
  47. public function testSetupDatabase()
  48. {
  49. $testAdapter = $this->getMock('Zend_Test_DbAdapter');
  50. $testAdapter->expects($this->any())
  51. ->method('delete')
  52. ->will($this->throwException(new Exception));
  53. $connection = new Zend_Test_PHPUnit_Db_Connection($testAdapter, "schema");
  54. $databaseTester = new Zend_Test_PHPUnit_Db_SimpleTester($connection);
  55. $dataSet = $this->getMock('PHPUnit_Extensions_Database_DataSet_IDataSet');
  56. $dataSet->expects($this->any())
  57. ->method('getIterator')
  58. ->will($this->returnValue($this->getMock('Iterator')));
  59. $dataSet->expects($this->any())
  60. ->method('getReverseIterator')
  61. ->will($this->returnValue($this->getMock('Iterator')));
  62. $databaseTester->setUpDatabase($dataSet);
  63. }
  64. public function testInvalidConnectionGivenThrowsException()
  65. {
  66. $this->setExpectedException("Zend_Test_PHPUnit_Db_Exception");
  67. $connection = $this->getMock('PHPUnit_Extensions_Database_DB_IDatabaseConnection');
  68. $databaseTester = new Zend_Test_PHPUnit_Db_SimpleTester($connection);
  69. }
  70. }