jeudi 27 février 2020

Test if methods from a ResultSet is called when doing a request

I want to test if this 2 methods are called when I am doing a request. How can I do this?

sub ordered_by {
  my ($self, $column, $type) = @_;
  my $order = $type eq 'asc' ? '-asc' : '-desc';
  return $self->search(undef, { order_by => [{ $order => $column },
    { -asc => 'username' }] });
}
sub with_num_comments {
  my $self = shift;
  return $self->search(undef, {
    '+select' => [
        {
          coalesce => $self->correlate('comments')->count_rs->as_query,
              -as => 'num_comments'
        }
   ],
   '+as' => [ 'num_comments' ],
 });
}

Aucun commentaire:

Enregistrer un commentaire