First, you set up a database connection object to a local database.
首先,您设置一个到本地数据库的数据库连接对象。
In this case, we would mock the query method of the database connection object so that we could just return back the results instead of calling out to the database for them.
在这里,我们可以模拟数据库连接对象的查询方法,这样我们就只需要返回结果,而不需要真正地去查询数据库。
Now you can pass in an object directly that is compatible with the expected database connection object, and it will use that object instead of creating a new one.
现在您可以直接传入一个对象,它与预期数据库连接对象相兼容,然后直接使用这个对象,而非创建一个新对象。
应用推荐