DbTableDataSetTest.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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-2010 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/Db/Table.php";
  24. require_once "Zend/Test/PHPUnit/Db/DataSet/DbTableDataSet.php";
  25. /**
  26. * @category Zend
  27. * @package Zend_Test
  28. * @subpackage UnitTests
  29. * @copyright Copyright (c) 2005-2010 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_DataSet_DbTableDataSetTest extends PHPUnit_Framework_TestCase
  34. {
  35. public function testAddTableAppendedToTableNames()
  36. {
  37. $fixtureTable = "foo";
  38. $table = $this->getMock('Zend_Db_Table', array(), array(), '', false);
  39. $table->expects($this->at(0))->method('info')->with('name')->will($this->returnValue($fixtureTable));
  40. $table->expects($this->at(1))->method('info')->with('name')->will($this->returnValue($fixtureTable));
  41. $table->expects($this->at(2))->method('info')->with('cols')->will($this->returnValue(array()));
  42. $dataSet = new Zend_Test_PHPUnit_Db_DataSet_DbTableDataSet();
  43. $dataSet->addTable($table);
  44. $this->assertEquals(array($fixtureTable), $dataSet->getTableNames());
  45. }
  46. public function testAddTableCreatesDbTableInstance()
  47. {
  48. $fixtureTable = "foo";
  49. $table = $this->getMock('Zend_Db_Table', array(), array(), '', false);
  50. $table->expects($this->at(0))->method('info')->with('name')->will($this->returnValue($fixtureTable));
  51. $table->expects($this->at(1))->method('info')->with('name')->will($this->returnValue($fixtureTable));
  52. $table->expects($this->at(2))->method('info')->with('cols')->will($this->returnValue(array()));
  53. $dataSet = new Zend_Test_PHPUnit_Db_DataSet_DbTableDataSet();
  54. $dataSet->addTable($table);
  55. $this->assertType('Zend_Test_PHPUnit_Db_DataSet_DbTable', $dataSet->getTable($fixtureTable));
  56. }
  57. public function testGetUnknownTableThrowsException()
  58. {
  59. $this->setExpectedException('InvalidArgumentException');
  60. $dataSet = new Zend_Test_PHPUnit_Db_DataSet_DbTableDataSet();
  61. $dataSet->getTable('unknown');
  62. }
  63. }