Esempio n. 1
0
 public function testMissingRelationshipsCauseExceptions()
 {
     $node = new Relax_Client_Model('Root', $this->connection);
     $node->hasMany('Customer');
     try {
         $node->relationship('blargh');
         $this->fail('missing relationships should throw an exception');
     } catch (BadMethodCallException $e) {
         $this->assertTrue(true);
     }
 }
Esempio n. 2
0
 public function testRoundTrip()
 {
     $model = new Relax_Client_Model($this->connection);
     $model->hasMany($model->define('Customer')->hasMany('Address', 'addresses')->hasMany('Transaction'));
     $model->customers()->create(array('name' => 'Lachlan'))->addresses()->create(array('street' => 'Oriel Rd'));
     $this->assertEquals($model->customers(1)->name, 'Lachlan');
     $this->assertEquals($model->customers(1)->addresses(1)->street, 'Oriel Rd');
     $model->customers(1)->set('name', 'Fred')->save();
     $model->customers(1)->addresses(1)->set('street', 'Some St')->save();
     $this->assertEquals($model->customers(1)->name, 'Fred');
     $this->assertEquals($model->customers(1)->addresses(1)->street, 'Some St');
 }