cvs: pear /MDB_QueryTool/tests/simpletest_tests mdb_querytool_testGet.php

From: Date: Mon, 01 May 2006 15:33:11 +0000
Subject: cvs: pear /MDB_QueryTool/tests/simpletest_tests mdb_querytool_testGet.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-39935@lists.php.net to get a copy of this message
quipo Mon May 1 15:33:11 2006 UTC Modified files: /pear/MDB_QueryTool/tests/simpletest_tests mdb_querytool_testGet.php Log: added new tests http://cvs.php.net/viewcvs.cgi/pear/MDB_QueryTool/tests/simpletest_tests/mdb_querytool_testGet.php?r1=1.5&r2=1.6&diff_format=u Index: pear/MDB_QueryTool/tests/simpletest_tests/mdb_querytool_testGet.php diff -u pear/MDB_QueryTool/tests/simpletest_tests/mdb_querytool_testGet.php:1.5 pear/MDB_QueryTool/tests/simpletest_tests/mdb_querytool_testGet.php:1.6 --- pear/MDB_QueryTool/tests/simpletest_tests/mdb_querytool_testGet.php:1.5 Fri Apr 22 14:37:02 2005 +++ pear/MDB_QueryTool/tests/simpletest_tests/mdb_querytool_testGet.php Mon May 1 15:33:11 2006 @@ -1,5 +1,5 @@ <?php -// $Id: mdb_querytool_testGet.php,v 1.5 2005/04/22 14:37:02 quipo Exp $ +// $Id: mdb_querytool_testGet.php,v 1.6 2006/05/01 15:33:11 quipo Exp $ require_once dirname(__FILE__).'/mdb_querytool_test_base.php'; @@ -9,8 +9,8 @@ function TestOfMDB_QueryTool_Get($name = __CLASS__) { $this->UnitTestCase($name); } - function test_AddGet() - { + + function test_AddGet() { $this->qt = new MDB_QT(TABLE_USER); $newData = $this->_getSampleData(1); @@ -28,6 +28,22 @@ $this->assertEqual($newData, $this->qt->get($id)); } + function test_GetTrimmed() { + $this->qt = new MDB_QT(TABLE_USER); + + $newData = $this->_getSampleData(1); + $newData['name'] = str_repeat($newData['name'], 10); //exceeds field size + $newData['address_id'] = 123456789012; //within 11 bytes - more than 11 digits + $id = $this->qt->add($newData); + $this->assertTrue($id != false); + + $newData['id'] = $id; + $retrieved = $this->qt->get($id); + + $this->assertEqual($newData['name'], $retrieved['name']); + $this->assertEqual($newData['address_id'], $retrieved['address_id']); + } + function test_AddGetPKNotInteger() { $this->qt = new MDB_QT(TABLE_TRANSLATION); $this->qt->primaryCol = 'string'; @@ -291,6 +307,43 @@ $this->assertEqual($right, $question->getJoin('right')); $this->assertEqual($left, $question->getJoin('left')); } + + function test_Get_Result_Array() { + $this->qt = new MDB_QT(TABLE_USER); + $newData = $this->_getSampleData(1); + $id = $this->qt->add($newData); + $this->assertTrue($id != false); + + $newData['id'] = $id; + $this->qt->useResult('array'); + $res = $this->qt->getAll(); + $retrieved = $res->fetchRow(); + + $this->assertEqual($newData['name'], $retrieved['name']); + $this->assertEqual($newData['address_id'], $retrieved['address_id']); + } + + function test_Get_Result_Object() { + $this->qt = new MDB_QT(TABLE_USER); + $newData = $this->_getSampleData(1); + $id = $this->qt->add($newData); + $this->assertTrue($id != false); + + $newData['id'] = $id; + $this->qt->useResult('object'); + $res = $this->qt->getAll(); + $retrieved = $res->fetchRow(); + + $this->assertEqual($newData['name'], $retrieved->name); + $this->assertEqual($newData['address_id'], $retrieved->address_id); + + //test getCol => scalar values instead of arrays + $this->qt->useResult('object'); + $res = $this->qt->getCol('ID'); + + $retrieved = $res->fetchRow(); + $this->assertEqual($newData['id'], $retrieved); + } } if (!defined('TEST_RUNNING')) {

« previous php.pear.cvs (#39935) next »