cvs: pear /MDB2/tests MDB2_manager_testcase.php
| From: | Lukas Smith | Date: | Fri, 14 Oct 2005 22:52:58 +0000 |
| Subject: | cvs: pear /MDB2/tests MDB2_manager_testcase.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-35556@lists.php.net to get a copy of this message | ||
lsmith Fri Oct 14 18:52:58 2005 EDT
Modified files:
/pear/MDB2/tests MDB2_manager_testcase.php
Log:
- focused index/constraint checks a bit
http://cvs.php.net/diff.php/pear/MDB2/tests/MDB2_manager_testcase.php?r1=1.26&r2=1.27&ty=u
Index: pear/MDB2/tests/MDB2_manager_testcase.php
diff -u pear/MDB2/tests/MDB2_manager_testcase.php:1.26
pear/MDB2/tests/MDB2_manager_testcase.php:1.27
--- pear/MDB2/tests/MDB2_manager_testcase.php:1.26 Fri Oct 14 18:03:24 2005
+++ pear/MDB2/tests/MDB2_manager_testcase.php Fri Oct 14 18:52:55 2005
@@ -42,7 +42,7 @@
// | Lorenzo Alberton <l dot alberton at quipo dot it> |
// +----------------------------------------------------------------------+
//
-// $Id: MDB2_manager_testcase.php,v 1.26 2005/10/14 22:03:24 quipo Exp $
+// $Id: MDB2_manager_testcase.php,v 1.27 2005/10/14 22:52:55 lsmith Exp $
require_once 'MDB2/Schema.php';
@@ -175,13 +175,7 @@
);
$name = 'simpleindex';
$result = $this->db->manager->createIndex($this->table, $name, $index);
- if (PEAR::isError($result)) {
- $this->assertFalse(true, 'Error creating index');
- } else {
- $indices = $this->db->manager->listTableIndexes($this->table);
- $this->assertFalse(PEAR::isError($indices), 'Error listing indices');
- $this->assertTrue(in_array($name, $indices), 'Error creating index');
- }
+ $this->assertFalse(PEAR::isError($result), 'Error creating index');
}
/**
@@ -201,13 +195,7 @@
);
$name = 'uniqueindex';
$result = $this->db->manager->createIndex($this->table, $name, $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 creating unique
index');
- }
+ $this->assertFalse(PEAR::isError($result), 'Error creating unique index');
}
/**
@@ -223,12 +211,11 @@
'sorting' => 'ascending',
),
),
- 'unique' => true,
);
- $name = 'uniqueindex';
+ $name = 'simpleindex';
$result = $this->db->manager->createIndex($this->table, $name, $index);
if (PEAR::isError($result)) {
- $this->assertFalse(true, 'Error creating unique index');
+ $this->assertFalse(true, 'Error creating index');
} else {
$result = $this->db->manager->dropIndex($this->table, $name);
$this->assertFalse(PEAR::isError($result), 'Error dropping index');
@@ -241,6 +228,31 @@
/**
*
*/
+ function testListIndexes() {
+ if (!$this->methodExists($this->db->manager, 'listTableIndexes')) {
+ return;
+ }
+ $index = array(
+ 'fields' => array(
+ 'name' => array(
+ 'sorting' => 'ascending',
+ ),
+ ),
+ );
+ $name = 'simpleindex';
+ $result = $this->db->manager->createIndex($this->table, $name, $index);
+ if (PEAR::isError($result)) {
+ $this->assertFalse(true, 'Error creating index');
+ } else {
+ $indices = $this->db->manager->listTableIndexes($this->table);
+ $this->assertFalse(PEAR::isError($indices), 'Error listing indices');
+ $this->assertTrue(in_array($name, $indices), 'Error listing indices');
+ }
+ }
+
+ /**
+ *
+ */
function testCreatePrimaryKey() {
if (!$this->methodExists($this->db->manager, 'createConstraint')) {
return;
@@ -255,13 +267,7 @@
);
$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');
- }
+ $this->assertFalse(PEAR::isError($result), 'Error creating primary index');
}
/**
@@ -286,9 +292,32 @@
} else {
$result = $this->db->manager->dropConstraint($this->table, $name);
$this->assertFalse(PEAR::isError($result), 'Error dropping primary key
index');
+ }
+ }
+
+ /**
+ *
+ */
+ function testListConstraints() {
+ if (!$this->methodExists($this->db->manager, 'listTableConstraint')) {
+ return;
+ }
+ $index = array(
+ 'fields' => array(
+ 'id' => 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->assertFalse(in_array($name, $constraints), 'Error dropping primary key
index');
+ $this->assertFalse(PEAR::isError($constraints), 'Error listing
constraints');
+ $this->assertTrue(in_array($name, $constraints), 'Error listing primary key
index');
}
}