unit testing - Writing a test in Laravel to determine if ORM items are in the correct order -
 I wrote a test to draw 10 articles from my database. I then wrote the code to pass the exam and this work Does. However, now I want to write a test to make sure that 10 articles dragging from the database are based on   Test Method:    Actual method:      If you are using   You can order your archive in this way:   descending order   created_at . I'm not sure how to know about this.   
 public function testPullTenArticles () {for ($ i = 0; $ i & lt; 20; $ i ++) {$ temp article = New paragraph; $ TempArticle- & gt; Save (); } $ This- & gt; Emphasizing value (10, calculation ($ this-> article-> getArticles (10))); }    
 public function getArticles ($ count) {$ article = Article :: take ($ count) - & gt; get (); Return $ article; }     by order  Retrieve your items, then you do not need to check it - those who are good people who are Laravel & amp; Corrective code has already been done.   
 $ articles = article :: orderBy ("created_at", "desc") - & gt; Le ($ count) - & gt; Find ();    
 
Comments
Post a Comment