Skip to content

Commit

Permalink
Updating some tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwoo committed Jan 23, 2013
1 parent de02772 commit ce86a4a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 46 deletions.
69 changes: 26 additions & 43 deletions tests/integration/data/CrudExtendedTest.php
Expand Up @@ -11,7 +11,7 @@
use lithium\data\Connections; use lithium\data\Connections;
use li3_couchbase\extensions\data\source\Couchbase; use li3_couchbase\extensions\data\source\Couchbase;
use li3_couchbase\tests\mocks\models\Companies; 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 { class CrudExtendedTest extends \lithium\test\Integration {


Expand All @@ -22,8 +22,8 @@ class CrudExtendedTest extends \lithium\test\Integration {
protected $_key = null; protected $_key = null;


public $data = array( public $data = array(
array('name' => 'StuffMart', 'active' => true), array('name' => 'Marine Store', 'active' => true),
array('name' => 'Ma \'n Pa\'s Data Warehousing & Bait Shop', 'active' => false) array('name' => 'Bait Shop', 'active' => false)
); );


/** /**
Expand Down Expand Up @@ -62,67 +62,50 @@ public function tearDown() {
//$this->db->connection->delete($this->_database); //$this->db->connection->delete($this->_database);
} }



public function testCreateType() { public function testCreateType() {
$company = Companies::create(array( $company = Companies::create($this->data[0]);
'gimme' => 'type'
));
$this->assertTrue($company->save()); $this->assertTrue($company->save());
$this->assertEqual("Marine Store", $company->name);
$this->assertEqual('companies', $company->_source); $this->assertEqual('companies', $company->_source);
$this->assertTrue($company->delete()); $this->assertTrue($company->delete());
} }


public function testCreateNoId() { public function testCreateNoId() {
$company = Companies::create(array( $company = Companies::create($this->data[0]);
'who' => 'am i?'
));

$this->assertTrue($company->save()); $this->assertTrue($company->save());
$this->assertTrue(!empty($company->id)); $this->assertTrue(40 == strlen($company->id));
$this->assertTrue($company->delete()); $this->assertTrue($company->delete());
} }


public function testCreateNoIdCustomKey() { public function testCreateWithId() {
$custom = CustomKeys::create(array( $company = Companies::create(array('id' => 'my_id'));
'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'
));

$this->assertTrue($company->save()); $this->assertTrue($company->save());
$this->assertEqual('supercool', $company->id); $this->assertEqual('my_id', $company->id);
$this->assertTrue($company->delete()); $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() { public function testCreateNoIdCollisionless() {
$company = Companies::create(array( $company = Companies::create($this->data[0]);
'name' => 'Acme'
));
$this->assertTrue($company->save()); $this->assertTrue($company->save());


$second = Companies::create(array( $second = Companies::create($this->data[0]);
'name' => 'Acme'
));
$this->assertTrue($second->save()); $this->assertTrue($second->save());

$this->assertNotEqual($company->id, $second->id); $this->assertNotEqual($company->id, $second->id);
$this->assertTrue($company->delete()); $this->assertTrue($company->delete());
$this->assertTrue($second->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());
}
} }
Expand Up @@ -2,14 +2,14 @@


namespace li3_couchbase\tests\mocks\models; namespace li3_couchbase\tests\mocks\models;


class CustomKeys extends \lithium\data\Model { class Custom extends \lithium\data\Model {


protected $_meta = array( protected $_meta = array(
'connection' => 'test-couchbase', 'connection' => 'test-couchbase',
'key' => 'my_identifier' 'key' => 'my_key'
); );


protected $_schema = array( protected $_schema = array(
'my_identifier' => array('type' => 'id') 'my_key' => array('type' => 'id')
); );
} }

0 comments on commit ce86a4a

Please sign in to comment.