Permalink
Browse files

Updating some tests.

  • Loading branch information...
1 parent de02772 commit ce86a4a1e758201d215607a25dadc1074b8d152b @gwoo gwoo committed Jan 23, 2013
Showing with 29 additions and 46 deletions.
  1. +26 −43 tests/integration/data/CrudExtendedTest.php
  2. +3 −3 tests/mocks/models/{CustomKeys.php → Custom.php}
@@ -11,7 +11,7 @@
use lithium\data\Connections;
use li3_couchbase\extensions\data\source\Couchbase;
use li3_couchbase\tests\mocks\models\Companies;
-use li3_couchbase\tests\mocks\models\CustomKeys;
+use li3_couchbase\tests\mocks\models\Custom;
class CrudExtendedTest extends \lithium\test\Integration {
@@ -22,8 +22,8 @@ class CrudExtendedTest extends \lithium\test\Integration {
protected $_key = null;
public $data = array(
- array('name' => 'StuffMart', 'active' => true),
- array('name' => 'Ma \'n Pa\'s Data Warehousing & Bait Shop', 'active' => false)
+ array('name' => 'Marine Store', 'active' => true),
+ array('name' => 'Bait Shop', 'active' => false)
);
/**
@@ -62,67 +62,50 @@ public function tearDown() {
//$this->db->connection->delete($this->_database);
}
-
public function testCreateType() {
- $company = Companies::create(array(
- 'gimme' => 'type'
- ));
+ $company = Companies::create($this->data[0]);
$this->assertTrue($company->save());
+ $this->assertEqual("Marine Store", $company->name);
$this->assertEqual('companies', $company->_source);
$this->assertTrue($company->delete());
}
public function testCreateNoId() {
- $company = Companies::create(array(
- 'who' => 'am i?'
- ));
-
+ $company = Companies::create($this->data[0]);
$this->assertTrue($company->save());
- $this->assertTrue(!empty($company->id));
+ $this->assertTrue(40 == strlen($company->id));
$this->assertTrue($company->delete());
}
- public function testCreateNoIdCustomKey() {
- $custom = CustomKeys::create(array(
- 'how' => 'am I not myself?'
- ));
- $this->assertTrue($custom->save());
- $this->assertTrue(!empty($custom->my_identifier));
- $this->assertTrue($custom->delete());
- }
-
- public function testCreateId() {
- $company = Companies::create(array(
- 'id' => 'supercool'
- ));
-
+ public function testCreateWithId() {
+ $company = Companies::create(array('id' => 'my_id'));
$this->assertTrue($company->save());
- $this->assertEqual('supercool', $company->id);
+ $this->assertEqual('my_id', $company->id);
$this->assertTrue($company->delete());
}
- public function testCreateIdCustomKey() {
- $custom = CustomKeys::create(array(
- 'my_identifier' => 'my_key'
- ));
- $this->assertTrue($custom->save());
- $this->assertEqual('my_key', $custom->my_identifier);
- $this->assertTrue($custom->delete());
- }
-
public function testCreateNoIdCollisionless() {
- $company = Companies::create(array(
- 'name' => 'Acme'
- ));
+ $company = Companies::create($this->data[0]);
$this->assertTrue($company->save());
- $second = Companies::create(array(
- 'name' => 'Acme'
- ));
+ $second = Companies::create($this->data[0]);
$this->assertTrue($second->save());
-
$this->assertNotEqual($company->id, $second->id);
$this->assertTrue($company->delete());
$this->assertTrue($second->delete());
}
+
+ public function testCreateNoIdCustomKey() {
+ $custom = Custom::create();
+ $this->assertTrue($custom->save());
+ $this->assertTrue(!empty($custom->my_key));
+ $this->assertTrue($custom->delete());
+ }
+
+ public function testCreateIdCustomKey() {
+ $custom = Custom::create(array('my_key' => 'something'));
+ $this->assertTrue($custom->save());
+ $this->assertEqual('something', $custom->my_key);
+ $this->assertTrue($custom->delete());
+ }
}
@@ -2,14 +2,14 @@
namespace li3_couchbase\tests\mocks\models;
-class CustomKeys extends \lithium\data\Model {
+class Custom extends \lithium\data\Model {
protected $_meta = array(
'connection' => 'test-couchbase',
- 'key' => 'my_identifier'
+ 'key' => 'my_key'
);
protected $_schema = array(
- 'my_identifier' => array('type' => 'id')
+ 'my_key' => array('type' => 'id')
);
}

0 comments on commit ce86a4a

Please sign in to comment.