2
0

ConnectionTest.php 2.7 KB

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