SimpleTesterTest.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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-2014 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 "Zend/Test/PHPUnit/Db/Exception.php";
  26. /**
  27. * @category Zend
  28. * @package Zend_Test
  29. * @subpackage UnitTests
  30. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http://framework.zend.com/license/new-bsd New BSD License
  32. * @group Zend_Test
  33. */
  34. class Zend_Test_PHPUnit_Db_SimpleTesterTest extends PHPUnit_Framework_TestCase
  35. {
  36. public function testGetConnection()
  37. {
  38. $testAdapter = $this->getMock('Zend_Test_DbAdapter');
  39. $testAdapter->expects($this->any())
  40. ->method('delete')
  41. ->will($this->throwException(new Exception));
  42. $connection = new Zend_Test_PHPUnit_Db_Connection($testAdapter, "schema");
  43. $databaseTester = new Zend_Test_PHPUnit_Db_SimpleTester($connection);
  44. $this->assertSame($connection, $databaseTester->getConnection());
  45. }
  46. public function testSetupDatabase()
  47. {
  48. $testAdapter = $this->getMock('Zend_Test_DbAdapter');
  49. $testAdapter->expects($this->any())
  50. ->method('delete')
  51. ->will($this->throwException(new Exception));
  52. $connection = new Zend_Test_PHPUnit_Db_Connection($testAdapter, "schema");
  53. $databaseTester = new Zend_Test_PHPUnit_Db_SimpleTester($connection);
  54. $dataSet = $this->getMock('PHPUnit_Extensions_Database_DataSet_IDataSet');
  55. $dataSet->expects($this->any())
  56. ->method('getIterator')
  57. ->will($this->returnValue($this->getMock('Iterator')));
  58. $dataSet->expects($this->any())
  59. ->method('getReverseIterator')
  60. ->will($this->returnValue($this->getMock('Iterator')));
  61. $databaseTester->setUpDatabase($dataSet);
  62. }
  63. public function testInvalidConnectionGivenThrowsException()
  64. {
  65. $this->setExpectedException("Zend_Test_PHPUnit_Db_Exception");
  66. $connection = $this->getMock('PHPUnit_Extensions_Database_DB_IDatabaseConnection');
  67. $databaseTester = new Zend_Test_PHPUnit_Db_SimpleTester($connection);
  68. }
  69. }