cvs: pear /MDB2/tests MDB2_manager_testcase.php MDB2_reverse_testcase.php

From: Date: Fri, 14 Oct 2005 16:30:37 +0000
Subject: cvs: pear /MDB2/tests MDB2_manager_testcase.php MDB2_reverse_testcase.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-35530@lists.php.net to get a copy of this message
lsmith Fri Oct 14 12:30:37 2005 EDT Modified files: /pear/MDB2/tests MDB2_manager_testcase.php MDB2_reverse_testcase.php Log: - use new contraint specific methods

http://cvs.php.net/diff.php/pear/MDB2/tests/MDB2_manager_testcase.php?r1=1.23&r2=1.24&ty=u Index: pear/MDB2/tests/MDB2_manager_testcase.php diff -u pear/MDB2/tests/MDB2_manager_testcase.php:1.23 pear/MDB2/tests/MDB2_manager_testcase.php:1.24 --- pear/MDB2/tests/MDB2_manager_testcase.php:1.23 Fri Oct 14 06:21:56 2005 +++ pear/MDB2/tests/MDB2_manager_testcase.php Fri Oct 14 12:30:37 2005 @@ -42,7 +42,7 @@ // | Lorenzo Alberton <l dot alberton at quipo dot it> | // +----------------------------------------------------------------------+ // -// $Id: MDB2_manager_testcase.php,v 1.23 2005/10/14 10:21:56 lsmith Exp $ +// $Id: MDB2_manager_testcase.php,v 1.24 2005/10/14 16:30:37 lsmith Exp $ require_once 'MDB2/Schema.php'; @@ -175,10 +175,13 @@ ); $name = 'simpleindex'; $result = $this->db->manager->createIndex($this->table, $name, $index); - $this->assertFalse(PEAR::isError($result), 'Error creating index'); - $indices = $this->db->manager->listTableIndexes($this->table); - $this->assertFalse(PEAR::isError($indices), 'Error listing indices'); - $this->assertTrue(in_array($name, $indices), 'Error creating index'); + if (PEAR::isError($result)) { + $this->assertFalse(true, 'Error creating unique index'); + } else { + $indices = $this->db->manager->listTableIndexes($this->table); + $this->assertFalse(PEAR::isError($indices), 'Error listing indices'); + $this->assertTrue(in_array($name, $indices), 'Error dropping index'); + } } /** @@ -198,17 +201,20 @@ ); $name = 'uniqueindex'; $result = $this->db->manager->createIndex($this->table, $name, $index); - $this->assertFalse(PEAR::isError($result), 'Error creating unique index'); - $indices = $this->db->manager->listTableIndexes($this->table); - $this->assertFalse(PEAR::isError($indices), 'Error listing indices'); - $this->assertTrue(in_array($name, $indices), 'Error creating unique index'); + if (PEAR::isError($result)) { + $this->assertFalse(true, 'Error creating unique index'); + } else { + $indices = $this->db->manager->listTableIndexes($this->table); + $this->assertFalse(PEAR::isError($indices), 'Error listing indices'); + $this->assertTrue(in_array($name, $indices), 'Error dropping index'); + } } /** * */ - function testCreatePrimaryKey() { - if (!$this->methodExists($this->db->manager, 'createIndex')) { + function testDropIndex() { + if (!$this->methodExists($this->db->manager, 'dropIndex')) { return; } $index = array( @@ -217,46 +223,73 @@ 'sorting' => 'ascending', ), ), - 'primary' => true, + 'unique' => true, ); - $name = 'pkindex'; + $name = 'uniqueindex'; $result = $this->db->manager->createIndex($this->table, $name, $index); - $this->assertFalse(PEAR::isError($result), 'Error creating primary index'); - $indices = $this->db->manager->listTableIndexes($this->table); - $this->assertFalse(PEAR::isError($indices), 'Error listing indices'); - $this->assertTrue(in_array($name, $indices), 'Error creating primary index'); + if (PEAR::isError($result)) { + $this->assertFalse(true, 'Error creating unique index'); + } else { + $result = $this->db->manager->dropIndex($this->table, $name); + $this->assertFalse(PEAR::isError($result), 'Error dropping index'); + $indices = $this->db->manager->listTableIndexes($this->table); + $this->assertFalse(PEAR::isError($indices), 'Error listing indices'); + $this->assertFalse(in_array($name, $indices), 'Error dropping index'); + } } /** * */ - function testDropIndex() { - if (!$this->methodExists($this->db->manager, 'dropIndex')) { + function testCreatePrimaryKey() { + if (!$this->methodExists($this->db->manager, 'createConstraint')) { return; } - $this->testCreateIndex(); - $name = 'simpleindex'; - $result = $this->db->manager->dropIndex($this->table, $name); - $this->assertFalse(PEAR::isError($result), 'Error dropping index'); - $indices = $this->db->manager->listTableIndexes($this->table); - $this->assertFalse(PEAR::isError($indices), 'Error listing indices'); - $this->assertFalse(in_array($name, $indices), 'Error dropping index'); + $index = array( + 'fields' => array( + 'name' => array( + 'sorting' => 'ascending', + ), + ), + 'primary' => true, + ); + $name = 'pkindex'; + $result = $this->db->manager->createConstraint($this->table, $name, $index); + if (PEAR::isError($result)) { + $this->assertFalse(true, 'Error creating primary index'); + } else { + $constraints = $this->db->manager->listTableConstraints($this->table); + $this->assertFalse(PEAR::isError($constraints), 'Error listing indices'); + $this->assertTrue(in_array($name, $constraints), 'Error creating primary index'); + } } /** * */ function testDropPrimaryKey() { - if (!$this->methodExists($this->db->manager, 'dropIndex')) { + if (!$this->methodExists($this->db->manager, 'dropConstraint')) { return; } - $this->testCreatePrimaryKey(); + $index = array( + 'fields' => array( + 'name' => array( + 'sorting' => 'ascending', + ), + ), + 'primary' => true, + ); $name = 'pkindex'; - $result = $this->db->manager->dropIndex($this->table, $name); - $this->assertFalse(PEAR::isError($result), 'Error dropping primary key index'); - $indices = $this->db->manager->listTableIndexes($this->table); - $this->assertFalse(PEAR::isError($indices), 'Error listing indices'); - $this->assertFalse(in_array($name, $indices), 'Error dropping primary key index'); + $result = $this->db->manager->createConstraint($this->table, $name, $index); + if (PEAR::isError($result)) { + $this->assertFalse(true, 'Error creating primary index'); + } else { + $result = $this->db->manager->dropConstraint($this->table, $name); + $this->assertFalse(PEAR::isError($result), 'Error dropping primary key index'); + $constraints = $this->db->manager->listTableConstraints($this->table); + $this->assertFalse(PEAR::isError($constraints), 'Error listing indices'); + $this->assertFalse(in_array($name, $constraints), 'Error dropping primary key index'); + } } /** http://cvs.php.net/diff.php/pear/MDB2/tests/MDB2_reverse_testcase.php?r1=1.15&r2=1.16&ty=u Index: pear/MDB2/tests/MDB2_reverse_testcase.php diff -u pear/MDB2/tests/MDB2_reverse_testcase.php:1.15 pear/MDB2/tests/MDB2_reverse_testcase.php:1.16 --- pear/MDB2/tests/MDB2_reverse_testcase.php:1.15 Fri Oct 14 06:21:56 2005 +++ pear/MDB2/tests/MDB2_reverse_testcase.php Fri Oct 14 12:30:37 2005 @@ -41,7 +41,7 @@ // | Author: Lorenzo Alberton <l dot alberton at quipo dot it> | // +----------------------------------------------------------------------+ // -// $Id: MDB2_reverse_testcase.php,v 1.15 2005/10/14 10:21:56 lsmith Exp $ +// $Id: MDB2_reverse_testcase.php,v 1.16 2005/10/14 16:30:37 lsmith Exp $ class MDB2_Reverse_TestCase extends PHPUnit_TestCase { @@ -230,14 +230,6 @@ ), 'unique' => true, ), - 'pkindex' => array( - 'fields' => array( - 'id' => array( - 'sorting' => 'ascending', - ), - ), - 'primary' => true, - ), 'multipleindex' => array( 'fields' => array( 'description' => array( @@ -266,9 +258,6 @@ if (!empty($index['unique'])) { $this->assertTrue($result['unique'], 'Error: missing UNIQUE constraint'); } - if (!empty($index['primary'])) { - $this->assertTrue($result['primary'], 'Error: missing PRIMARY KEY constraint'); - } } }
« previous php.pear.cvs (#35530) next »