cvs: pear /MDB2/tests MDB2_manager_testcase.php
| From: | Lukas Smith | Date: | Thu, 13 Oct 2005 14:47:49 +0000 |
| Subject: | cvs: pear /MDB2/tests MDB2_manager_testcase.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-35500@lists.php.net to get a copy of this message | ||
lsmith Thu Oct 13 10:47:49 2005 EDT
Modified files:
/pear/MDB2/tests MDB2_manager_testcase.php
Log:
- tweaked index tests
- removed unnecessary tableExists() calls
http://cvs.php.net/diff.php/pear/MDB2/tests/MDB2_manager_testcase.php?r1=1.20&r2=1.21&ty=u
Index: pear/MDB2/tests/MDB2_manager_testcase.php
diff -u pear/MDB2/tests/MDB2_manager_testcase.php:1.20
pear/MDB2/tests/MDB2_manager_testcase.php:1.21
--- pear/MDB2/tests/MDB2_manager_testcase.php:1.20 Thu Oct 13 10:22:48 2005
+++ pear/MDB2/tests/MDB2_manager_testcase.php Thu Oct 13 10:47:47 2005
@@ -42,7 +42,7 @@
// | Lorenzo Alberton <l dot alberton at quipo dot it> |
// +----------------------------------------------------------------------+
//
-// $Id: MDB2_manager_testcase.php,v 1.20 2005/10/13 14:22:48 lsmith Exp $
+// $Id: MDB2_manager_testcase.php,v 1.21 2005/10/13 14:47:47 lsmith Exp $
require_once 'MDB2/Schema.php';
@@ -150,15 +150,11 @@
if (!$this->methodExists($this->db->manager, 'listTableFields')) {
return;
}
- if (!$this->tableExists()) {
- $this->assertTrue(false, 'Table does not exists');
- } else {
- $this->assertEquals(
- array_keys($this->fields),
- $this->db->manager->listTableFields($this->table),
- 'Error creating table: incorrect fields'
- );
- }
+ $this->assertEquals(
+ array_keys($this->fields),
+ $this->db->manager->listTableFields($this->table),
+ 'Error creating table: incorrect fields'
+ );
}
/**
@@ -168,24 +164,42 @@
if (!$this->methodExists($this->db->manager, 'createIndex')) {
return;
}
- if (!$this->tableExists()) {
- $this->assertTrue(false, 'Table does not exists');
- } else {
- $index = array(
- 'fields' => array(
- 'name' => array(
- 'sorting' => 'ascending',
- ),
+ $index = array(
+ 'fields' => array(
+ 'name' => array(
+ 'sorting' => 'ascending',
),
- 'unique' => true,
- );
- $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');
+ ),
+ );
+ $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');
+ }
+
+ /**
+ *
+ */
+ function testCreateUniqueIndex() {
+ if (!$this->methodExists($this->db->manager, 'createIndex')) {
+ return;
}
+ $index = array(
+ 'fields' => array(
+ 'name' => array(
+ 'sorting' => 'ascending',
+ ),
+ ),
+ 'unique' => true,
+ );
+ $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');
}
/**
@@ -195,24 +209,20 @@
if (!$this->methodExists($this->db->manager, 'createIndex')) {
return;
}
- if (!$this->tableExists()) {
- $this->assertTrue(false, 'Table does not exists');
- } else {
- $index = array(
- 'fields' => array(
- 'id' => array(
- 'sorting' => 'ascending',
- ),
+ $index = array(
+ 'fields' => array(
+ 'name' => array(
+ 'sorting' => 'ascending',
),
- 'primary' => true,
- );
- $name = 'primary';
- $result = $this->db->manager->createIndex($this->table, $name, $index);
- $this->assertFalse(PEAR::isError($result), 'Error creating primary key
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 key
index');
- }
+ ),
+ 'primary' => true,
+ );
+ $name = 'primary';
+ $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');
}
/**
@@ -223,12 +233,12 @@
return;
}
$this->testCreateIndex();
- $name = 'uniqueindex';
+ $name = 'simpleindex';
$result = $this->db->manager->dropIndex($this->table, $name);
- $this->assertFalse(PEAR::isError($result), 'Error dropping unique index');
+ $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 unique index');
+ $this->assertFalse(in_array($name, $indices), 'Error dropping index');
}
/**
@@ -294,9 +304,6 @@
),
),
);
- if (!$this->tableExists()) {
- $this->db->manager->createTable($this->table, $this->fields);
- }
$result = $this->db->manager->alterTable($this->table, $changes, false);
$this->assertFalse(PEAR::isError($result), 'Error altering table');