Beispiel #1
0
 public function testFlushCacheForBatchInsert()
 {
     $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', '343a10e6c2480e111dd3e9e564eb7966']);
     User::insert([['id' => 1, 'name' => '海涛'], ['id' => 2, 'name' => 'haitao']]);
 }