All Questions
8 questions
0
votes
1
answer
669
views
Unit tests involving library functions and objects
I am making a project using the Laravel framework.
I plan to create unit tests for my project. But I feel I don't really have an idea what to test because I mostly use library or framework functions. ...
1
vote
1
answer
1k
views
How to unit test database queries based on current date?
Is there a feasible way of testing SQL queries that contain things like CURRENT_DATE and NOW() in a unit test?
For example:
public function deletePastEntries(): bool {
$sql = "DELETE FROM queue ...
2
votes
4
answers
2k
views
How to write a unit test for a repository method that returns some data, where data can change over time?
I have some code that reads five numbers from a database:
class Repository extends DatabaseRepository
{
function getCoefficients(string $model)
{
return $this->getDatabaseLink()-&...
-1
votes
1
answer
184
views
How to approach writing a 'test' for a series of input->output sets, that will later be used to verify correctness of a new system?
I have a system ("an engine", which is a piece of code) that takes in several parameters returns some output. The input parameters are several distinct and constrained sets. I can enumerate all of ...
3
votes
2
answers
3k
views
How unit test service method that use repository method
For service methods that call repository methods to interact with database how could I unit test these service methods?
For example,
public function updateSlideshow($data){
// do some logic and ...
6
votes
2
answers
2k
views
How well am I writing my tests?
I've been coding as a career for about 2 years now but am just now writing my first "real" tests for a non-trivial application. I've been trying to follow best practices I've picked up from the ...
0
votes
1
answer
168
views
Test logic with external data [duplicate]
I have a site programmed in PHP where I make more call to external server that return me big xml of data.
For each record of the xml I have to make other external call to get other data.
So my ...
1
vote
1
answer
2k
views
PHPUnit > Best approach to mock container objects? (e.g. $item->id)
I'm using PHPUnit test doubles to mock models, libraries etc. But when I want to return an array perhaps of container objects, how best to do so. Here is what I'm currently doing:
/**
* This is just ...