| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- <?php
- /**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Db
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id$
- */
- /**
- * @see Zend_Db_Table_TestCommon
- */
- require_once 'Zend/Db/Table/TestCommon.php';
- /**
- * @category Zend
- * @package Zend_Db
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @group Zend_Db
- * @group Zend_Db_Table
- */
- class Zend_Db_Table_Pdo_PgsqlTest extends Zend_Db_Table_TestCommon
- {
- public function getDriver()
- {
- return 'Pdo_Pgsql';
- }
- public function testTableInsert()
- {
- $table = $this->_table['bugs'];
- $row = array (
- 'bug_description' => 'New bug',
- 'bug_status' => 'NEW',
- 'created_on' => '2007-04-02',
- 'updated_on' => '2007-04-02',
- 'reported_by' => 'micky',
- 'assigned_to' => 'goofy'
- );
- $insertResult = $table->insert($row);
- $lastInsertId = $this->_db->lastInsertId('zfbugs', 'bug_id');
- $lastSequenceId = $this->_db->lastSequenceId('zfbugs_bug_id_seq');
- $this->assertEquals($insertResult, $lastInsertId);
- $this->assertEquals($insertResult, $lastSequenceId);
- $this->assertEquals(5, $lastInsertId);
- }
- public function testTableInsertPkNull()
- {
- $table = $this->_table['bugs'];
- $row = array (
- 'bug_id' => null,
- 'bug_description' => 'New bug',
- 'bug_status' => 'NEW',
- 'created_on' => '2007-04-02',
- 'updated_on' => '2007-04-02',
- 'reported_by' => 'micky',
- 'assigned_to' => 'goofy'
- );
- $insertResult = $table->insert($row);
- $lastInsertId = $this->_db->lastInsertId('zfbugs', 'bug_id');
- $lastSequenceId = $this->_db->lastSequenceId('zfbugs_bug_id_seq');
- $this->assertEquals($insertResult, $lastInsertId);
- $this->assertEquals($insertResult, $lastSequenceId);
- $this->assertEquals(5, $lastInsertId);
- }
- public function testTableInsertSequence()
- {
- $table = $this->_getTable('My_ZendDbTable_TableProducts',
- array(Zend_Db_Table_Abstract::SEQUENCE => 'zfproducts_seq'));
- $row = array (
- 'product_name' => 'Solaris'
- );
- $insertResult = $table->insert($row);
- $lastInsertId = $this->_db->lastInsertId('zfproducts');
- $lastSequenceId = $this->_db->lastSequenceId('zfproducts_seq');
- $this->assertEquals($insertResult, $lastInsertId);
- $this->assertEquals($insertResult, $lastSequenceId);
- $this->assertEquals(4, $insertResult);
- }
- /**
- * Ensures that the schema is null if not specified
- *
- * @return void
- */
- public function testTableSchemaNotSetIsNull()
- {
- $tableInfo = $this->_table['bugs']->info();
- $this->assertNull($tableInfo['schema']);
- }
- /**
- * Ensures that the schema is set by the 'schema' constructor configuration directive
- *
- * @return void
- */
- public function testTableSchemaSetByConstructorConfigSchema()
- {
- $schema = 'public';
- $config = array(
- 'db' => $this->_db,
- 'schema' => $schema
- );
- $table = new My_ZendDbTable_TableBugs($config);
- $tableInfo = $table->info();
- $this->assertEquals($schema, $tableInfo['schema']);
- }
- /**
- * Ensures that the schema is set by the 'name' constructor configuration directive
- *
- * @return void
- */
- public function testTableSchemaSetByConstructorConfigName()
- {
- $schema = 'public';
- $tableName = "$schema.zfbugs";
- $config = array(
- 'db' => $this->_db,
- 'name' => $tableName
- );
- $table = new My_ZendDbTable_TableBugs($config);
- $tableInfo = $table->info();
- $this->assertEquals($schema, $tableInfo['schema']);
- }
- /**
- * Ensures that a schema given in the 'name' constructor configuration directive overrides any schema specified
- * by the 'schema' constructor configuration directive.
- *
- * @return void
- */
- public function testTableSchemaConstructorConfigNameOverridesSchema()
- {
- $schema = 'public';
- $tableName = "$schema.zfbugs";
- $config = array(
- 'db' => $this->_db,
- 'schema' => 'foo',
- 'name' => $tableName
- );
- $table = new My_ZendDbTable_TableBugs($config);
- $tableInfo = $table->info();
- $this->assertEquals($schema, $tableInfo['schema']);
- }
- /**
- * Ensures that fetchAll() provides expected behavior when the schema is specified
- *
- * @return void
- */
- public function testTableFetchAllSchemaSet()
- {
- $schema = 'public';
- $config = array(
- 'db' => $this->_db,
- 'schema' => $schema,
- );
- $table = new My_ZendDbTable_TableBugs($config);
- $rowset = $table->fetchAll();
- $this->assertThat(
- $rowset,
- $this->isInstanceOf('Zend_Db_Table_Rowset')
- );
- $this->assertEquals(
- 4,
- count($rowset)
- );
- }
- }
|