Exemple #1
0
 public function testToArrayAfterCreate()
 {
     $data = array('id' => 1, 'name' => 'testname');
     Phactory::define('user', $data);
     $user = Phactory::create('user');
     $this->assertEquals($data, $user->toArray());
 }
Exemple #2
0
 public function testRecall()
 {
     $name = 'testuser';
     // define and create user in db
     Phactory::define('user', array('name' => $name));
     $user = Phactory::create('user');
     // recall() deletes from the db
     Phactory::recall();
     // test that the object is gone from the db
     $stmt = $this->pdo->query("SELECT * FROM `users`");
     $db_user = $stmt->fetch();
     $this->assertFalse($db_user);
     // test that the blueprints weren't destroyed too
     $user = Phactory::create('user');
     $this->assertEquals($user->name, $name);
 }
Exemple #3
0
 public function testRecall()
 {
     $name = 'testuser';
     // define and create user in db
     Phactory::define('user', array('name' => $name));
     $user = Phactory::create('user');
     // recall() deletes from the db
     Phactory::recall();
     // test that the object is gone from the db
     $db_user = $this->db->users->findOne();
     $this->assertNull($db_user);
     // test that the blueprints weren't destroyed too
     $user = Phactory::create('user');
     $this->assertEquals($user['name'], $name);
 }