ConnectionTest.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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/DbAdapter.php";
  23. require_once "Zend/Test/PHPUnit/Db/Connection.php";
  24. /**
  25. * @category Zend
  26. * @package Zend_Test
  27. * @subpackage UnitTests
  28. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  29. * @license http://framework.zend.com/license/new-bsd New BSD License
  30. * @group Zend_Test
  31. */
  32. class Zend_Test_PHPUnit_Db_ConnectionTest extends PHPUnit_Framework_TestCase
  33. {
  34. protected $adapterMock;
  35. public function setUp()
  36. {
  37. $this->adapterMock = $this->getMock('Zend_Test_DbAdapter');
  38. }
  39. /**
  40. * @return Zend_Test_PHPUnit_Db_Connection
  41. */
  42. public function createConnection()
  43. {
  44. $connection = new Zend_Test_PHPUnit_Db_Connection($this->adapterMock, "schema");
  45. return $connection;
  46. }
  47. public function testCloseConnection()
  48. {
  49. $this->adapterMock->expects($this->once())
  50. ->method('closeConnection');
  51. $connection = $this->createConnection();
  52. $connection->close();
  53. }
  54. public function testCreateQueryTable()
  55. {
  56. $connection = $this->createConnection();
  57. $ret = $connection->createQueryTable("foo", "foo");
  58. $this->assertTrue($ret instanceof Zend_Test_PHPUnit_Db_DataSet_QueryTable);
  59. }
  60. public function testGetSchema()
  61. {
  62. $fixtureSchema = "schema";
  63. $connection = new Zend_Test_PHPUnit_Db_Connection($this->adapterMock, $fixtureSchema);
  64. $this->assertEquals($fixtureSchema, $connection->getSchema());
  65. }
  66. public function testGetMetaData()
  67. {
  68. $connection = $this->createConnection();
  69. $metadata = $connection->getMetaData();
  70. $this->assertTrue($metadata instanceof Zend_Test_PHPUnit_Db_Metadata_Generic);
  71. }
  72. public function testGetTruncateCommand()
  73. {
  74. $connection = $this->createConnection();
  75. $this->assertEquals("DELETE", $connection->getTruncateCommand());
  76. }
  77. }