Beispiel #1
0
 public function testCreateModel()
 {
     $indonesia = new Country(array('name' => 'Indonesia'));
     $indonesia->save();
     $user = new User(array('fullname' => 'Mukhamad Ikhsan', 'email' => '*****@*****.**', 'password' => 'rahasia', 'profile' => array('profession' => 'programmer', 'nationality' => $indonesia)));
     $this->assertEqual('Mukhamad Ikhsan', $user->fullname);
     $this->assertEqual('programmer', $user->profile->profession);
     $this->assertEqual('Indonesia', $user->profile->nationality->name);
     $this->assertTrue($user->save());
     $ikhsan = User::getRepository()->findOneBy(array('email' => '*****@*****.**'));
     $users = User::findAll(array('where' => array('and' => array(array('fullname' => array('like' => '%Ikhsan')), array('fullname' => array('eq' => 'Mukhamad Ikhsan')), array('fullname' => array('neq' => 'Haris Riswandi')))), 'leftJoin' => array(array('field' => 'groups'))));
     $compacts = User::getCompactList('fullname');
     $this->assertEqual(1, count($users));
     $this->assertEqual(1, count($compacts));
     $this->assertEqual('Mukhamad Ikhsan', $ikhsan->fullname);
     $this->assertEqual('programmer', $ikhsan->profile->profession);
     $this->assertEqual('Indonesia', $ikhsan->profile->nationality->name);
     $ikhsan->delete();
     $indonesia->delete();
     $this->assertNull(User::getRepository()->findOneBy(array('email' => '*****@*****.**')));
     $this->assertNull(Country::getRepository()->findOneBy(array('name' => 'Indonesia')));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param Country $pais
  * @return Response
  * @internal param int $id
  */
 public function destroy(Country $pais)
 {
     $pais->delete();
     return redirect('/paises');
 }