Beispiel #1
0
 public function testFlushCacheForInsert()
 {
     $pdo = M::mock('\\PDO');
     // 模拟数据库返回自增主键 ID
     $pdo->shouldReceive('lastInsertId')->andReturn(1);
     $this->conn->shouldReceive('getPdo')->andReturn($pdo);
     $this->conn->shouldReceive('insert');
     // 模拟刷新表级缓存
     $this->meta->shouldReceive('flush')->with('angejia', 'user');
     $this->cache->shouldReceive('del')->with(['3558193cd9818af7fe4d2c2f5bd9d00f']);
     $user = new User();
     $user->name = '海涛';
     $user->save();
     $this->assertEquals(1, $user->id);
 }