{"action":"created","comment":{"url":"https://api.github.com/repos/AT-PHPIntership/book-library/pulls/comments/165248088","pull_request_review_id":93152397,"id":165248088,"diff_hunk":"@@ -0,0 +1,874 @@\n+<?php\n+\n+namespace Tests\\Browser\\tests\\Browser\\Pages\\BackEnd\\Books;\n+\n+use App\\Model\\Book;\n+use App\\Model\\Borrowing;\n+use App\\Model\\Category;\n+use App\\Model\\Donator;\n+use App\\Model\\User;\n+use Tests\\DuskTestCase;\n+use Laravel\\Dusk\\Browser;\n+use Illuminate\\Foundation\\Testing\\DatabaseMigrations;\n+use Illuminate\\Support\\Facades\\DB;\n+use Faker\\Factory as Faker;\n+use Carbon\\Carbon;\n+\n+class SortBorrowingsTest extends DuskTestCase\n+{\n+    use DatabaseMigrations;\n+\n+    /**\n+     * Create virtual database\n+     *\n+     * @return void\n+     */\n+    public function makeborrowings($rows)\n+    {\n+        $faker = Faker::create();\n+        factory(Category::class)->create();\n+        factory(User::class, $rows)->create();\n+        $userIds = DB::table('users')->pluck('id')->toArray();\n+        factory(Donator::class, 10)->create([\n+            'user_id' => $faker->unique()->randomElement($userIds),\n+        ]);\n+        $categoryIds = DB::table('categories')->pluck('id')->toArray();\n+        $donatorIds = DB::table('donators')->pluck('id')->toArray();\n+        factory(Book::class, $rows+1)->create([\n+            'category_id' => $faker->randomElement($categoryIds),\n+            'donator_id' => $faker->randomElement($donatorIds),\n+        ]);\n+        $bookIds = DB::table('books')->pluck('id')->toArray();\n+        foreach ($userIds as $id) {\n+            factory(Borrowing::class)->create([\n+                'user_id' => $id,\n+                'book_id' => $faker->randomElement($bookIds),\n+            ]);\n+        }\n+    }\n+\n+    /**\n+     * Create virtual database\n+     *\n+     * @return void\n+     */\n+    public function makeUser()\n+    {\n+        factory(User::class)->create([\n+            'role' => User::ROOT_ADMIN\n+        ]);\n+    }\n+\n+    /**\n+     * Test sort ASC Employee_code\n+     *\n+     * @return void\n+     */\n+    public function testSortEmployeeCodeASC()\n+    {\n+        $this->makeUser();\n+        $this->makeborrowings(16);\n+        $this->browse(function (Browser $browser) {\n+            $browser->loginAs(User::find(1))\n+                    ->visit('/admin/borrowings/')\n+                    ->resize(900, 1600)\n+                    ->clickLink('Employee code')\n+                    ->assertVisible('.fa.fa-sort-asc')\n+                    ->screenshot(1);\n+            $borrowings = Borrowing::Join('users', 'borrowings.user_id', '=', 'users.id')\n+                ->Join('books', 'borrowings.book_id', '=', 'books.id')\n+                ->orderBy('employee_code', 'ASC')\n+                ->limit(10)->get();\n+\n+            $checkEmployeeCode = false;\n+            foreach ($borrowings as $index => $borrowing) {\n+                $borrowingEmployeeCode = $browser->text('#table-borrowings tbody tr:nth-child(' . (string)($index + 1) . ') td:nth-child(1)');\n+                $checkEmployeeCode = $borrowing->employee_code == $borrowingEmployeeCode;\n+                if (!$checkEmployeeCode) {\n+                    break;\n+                }\n+            }\n+            $this->assertTrue($checkEmployeeCode);\n+        });\n+    }\n+\n+    /**\n+     * Test sort DESC Employee_code\n+     *\n+     * @return void\n+     */\n+    public function testSortEmployeeCodeDESC()\n+    {\n+        $this->makeUser();\n+        $this->makeborrowings(16);\n+        $this->browse(function (Browser $browser) {\n+            $browser->loginAs(User::find(1))\n+                    ->visit('/admin/borrowings/')\n+                    ->resize(900, 1600)\n+                    ->clickLink('Employee code')\n+                    ->clickLink('Employee code')\n+                    ->assertVisible('.fa.fa-sort-desc')\n+                    ->screenshot(1);\n+            $borrowings = Borrowing::Join('users', 'borrowings.user_id', '=', 'users.id')\n+                ->Join('books', 'borrowings.book_id', '=', 'books.id')\n+                ->orderBy('employee_code', 'desc')\n+                ->limit(10)->get();\n+\n+            $checkEmployeeCode = false;\n+            foreach ($borrowings as $index => $borrowing) {\n+                $borrowingEmployeeCode = $browser->text('#table-borrowings tbody tr:nth-child(' . (string)($index + 1) . ') td:nth-child(1)');\n+                $checkEmployeeCode = $borrowing->employee_code == $borrowingEmployeeCode;\n+                if (!$checkEmployeeCode) {\n+                    break;\n+                }\n+            }\n+            $this->assertTrue($checkEmployeeCode);\n+        });\n+    }\n+\n+    /**\n+     * Test sort DESC Employee_code has pagination\n+     *\n+     * @return void\n+     */\n+    public function testSortEmployeeCodeDESCWithPagination()\n+    {\n+        $this->makeUser();\n+        $this->makeborrowings(14);\n+        $this->browse(function (Browser $browser) {\n+            $page = $browser->loginAs(User::find(1))\n+                    ->visit('/admin/borrowings?sort=users.employee_code&order=desc&page=2')\n+                    ->resize(900, 1600)\n+                    ->assertVisible('.fa.fa-sort-desc')\n+                    ->screenshot(1);\n+            $elements = $page->elements('#table-borrowings tbody tr');\n+            $this->assertCount(5, $elements);\n+            $borrowings = Borrowing::Join('users', 'borrowings.user_id', '=', 'users.id')\n+                ->Join('books', 'borrowings.book_id', '=', 'books.id')\n+                ->orderBy('employee_code', 'desc')\n+                ->skip(10)->take(5)->get();\n+\n+            $checkEmployeeCode = false;\n+            foreach ($borrowings as $index => $borrowing) {\n+                $borrowingEmployeeCode = $browser->text('#table-borrowings tbody tr:nth-child(' . (string)($index + 1) . ') td:nth-child(1)');\n+                $checkEmployeeCode = $borrowing->employee_code == $borrowingEmployeeCode;\n+                if (!$checkEmployeeCode) {\n+                    break;\n+                }\n+            }\n+            $this->assertTrue($checkEmployeeCode);\n+        });\n+    }\n+\n+    /**\n+     * Test sort ASC Employee_code has pagination\n+     *\n+     * @return void\n+     */\n+    public function testSortEmployeeCodeASCWithPagination()\n+    {\n+        $this->makeUser();\n+        $this->makeborrowings(14);\n+        $this->browse(function (Browser $browser) {\n+            $page = $browser->loginAs(User::find(1))\n+                    ->visit('/admin/borrowings?sort=users.employee_code&order=asc&page=2')\n+                    ->resize(900, 1600)\n+                    ->assertVisible('.fa.fa-sort-asc')\n+                    ->screenshot(1);\n+            $elements = $page->elements('#table-borrowings tbody tr');\n+            $this->assertCount(5, $elements);\n+            $borrowings = Borrowing::Join('users', 'borrowings.user_id', '=', 'users.id')\n+                ->Join('books', 'borrowings.book_id', '=', 'books.id')\n+                ->orderBy('employee_code', 'asc')\n+                ->skip(10)->take(5)->get();\n+\n+            $checkEmployeeCode = false;\n+            foreach ($borrowings as $index => $borrowing) {\n+                $borrowingEmployeeCode = $browser->text('#table-borrowings tbody tr:nth-child(' . (string)($index + 1) . ') td:nth-child(1)');\n+                $checkEmployeeCode = $borrowing->employee_code == $borrowingEmployeeCode;\n+                if (!$checkEmployeeCode) {\n+                    break;\n+                }\n+            }\n+            $this->assertTrue($checkEmployeeCode);\n+        });\n+    }\n+\n+    /**\n+     * Test sort ASC Name has pagination\n+     *\n+     * @return void\n+     */\n+    public function testSortNameASCWithPagination()\n+    {\n+        $this->makeUser();\n+        $this->makeborrowings(14);\n+        $this->browse(function (Browser $browser) {\n+            $page = $browser->loginAs(User::find(1))\n+                    ->visit('/admin/borrowings?sort=users.name&order=asc&page=2')\n+                    ->assertVisible('.fa.fa-sort-asc')\n+                    ->resize(900, 1600)\n+                    ->screenshot(1);\n+\n+            $elements = $page->elements('#table-borrowings tbody tr');\n+            $this->assertCount(5, $elements);\n+            $borrowings = Borrowing::Join('users', 'borrowings.user_id', '=', 'users.id')\n+                ->Join('books', 'borrowings.book_id', '=', 'books.id')\n+                ->orderBy('users.name', 'asc')\n+                ->skip(10)->take(5)->get();\n+\n+            $checkName = false;\n+            foreach ($borrowings as $index => $borrowing) {\n+                $borrowingName = $browser->text('#table-borrowings tbody tr:nth-child(' . (string)($index + 1) . ') td:nth-child(2)');\n+                $checkName = $borrowing->users->name == $borrowingName;\n+                if (!$checkName) {\n+                    break;\n+                }\n+            }\n+            $this->assertTrue($checkName);\n+        });\n+    }\n+\n+    /**\n+     * Test sort DESC Name has pagination\n+     *\n+     * @return void\n+     */\n+    public function testSortNameDESCWithPagination()\n+    {\n+        $this->makeUser();\n+        $this->makeborrowings(14);\n+        $this->browse(function (Browser $browser) {\n+            $page = $browser->loginAs(User::find(1))\n+                    ->visit('/admin/borrowings?sort=users.name&order=desc&page=2')\n+                    ->assertVisible('.fa.fa-sort-desc')\n+                    ->resize(900, 1600)\n+                    ->screenshot(1);\n+\n+            $elements = $page->elements('#table-borrowings tbody tr');\n+            $this->assertCount(5, $elements);\n+            $borrowings = Borrowing::Join('users', 'borrowings.user_id', '=', 'users.id')\n+                ->Join('books', 'borrowings.book_id', '=', 'books.id')\n+                ->orderBy('users.name', 'desc')\n+                ->skip(10)->take(5)->get();\n+\n+            $checkName = false;\n+            foreach ($borrowings as $index => $borrowing) {\n+                $borrowingName = $browser->text('#table-borrowings tbody tr:nth-child(' . (string)($index + 1) . ') td:nth-child(2)');\n+                $checkName = $borrowing->users->name == $borrowingName;\n+                if (!$checkName) {\n+                    break;\n+                }\n+            }\n+            $this->assertTrue($checkName);\n+        });\n+    }\n+\n+    /**\n+     * Test sort DESC Name\n+     *\n+     * @return void\n+     */\n+    public function testSortNameDESC()\n+    {\n+        $this->makeUser();\n+        $this->makeborrowings(16);\n+        $this->browse(function (Browser $browser) {\n+            $browser->loginAs(User::find(1))\n+                    ->visit('/admin/borrowings/')\n+                    ->resize(900, 1600)\n+                    ->clickLink('Name')\n+                    ->clickLink('Name')\n+                    ->assertVisible('.fa.fa-sort-desc')\n+                    ->screenshot(1);\n+            $borrowings = Borrowing::Join('users', 'borrowings.user_id', '=', 'users.id')\n+                ->Join('books', 'borrowings.book_id', '=', 'books.id')\n+                ->orderBy('users.name', 'desc')\n+                ->limit(10)->get();\n+\n+            $checkName = false;\n+            foreach ($borrowings as $index => $borrowing) {\n+                $borrowingName = $browser->text('#table-borrowings tbody tr:nth-child(' . (string)($index + 1) . ') td:nth-child(2)');\n+                $checkName = $borrowing->users->name == $borrowingName;\n+                if (!$checkName) {\n+                    break;\n+                }\n+            }\n+            $this->assertTrue($checkName);\n+        });\n+    }\n+\n+    /**\n+        * Test sort ASC Name\n+     *\n+     * @return void\n+     */\n+    public function testSortNameASC()\n+    {\n+        $this->makeUser();\n+        $this->makeborrowings(16);\n+        $this->browse(function (Browser $browser) {\n+            $browser->loginAs(User::find(1))\n+                    ->visit('/admin/borrowings/')\n+                    ->resize(900, 1600)\n+                    ->clickLink('Name')\n+                    ->assertVisible('.fa.fa-sort-asc')\n+                    ->screenshot(1);\n+            $borrowings = Borrowing::Join('users', 'borrowings.user_id', '=', 'users.id')\n+                ->Join('books', 'borrowings.book_id', '=', 'books.id')\n+                ->orderBy('users.name', 'asc')\n+                ->limit(10)->get();\n+\n+            $checkName = false;\n+            foreach ($borrowings as $index => $borrowing) {\n+                $borrowingName = $browser->text('#table-borrowings tbody tr:nth-child(' . (string)($index + 1) . ') td:nth-child(2)');\n+                $checkName = $borrowing->users->name == $borrowingName;\n+                if (!$checkName) {\n+                    break;\n+                }\n+            }\n+            $this->assertTrue($checkName);\n+        });\n+    }\n+\n+    /**\n+     * Test sort ASC Email\n+     *\n+     * @return void\n+     */\n+    public function testSortEmailASC()\n+    {\n+        $this->makeUser();\n+        $this->makeborrowings(16);\n+        $this->browse(function (Browser $browser) {\n+            $browser->loginAs(User::find(1))\n+                ->visit('/admin/borrowings/')\n+                ->resize(900, 1600)\n+                ->clickLink('Email')\n+                ->assertVisible('.fa.fa-sort-asc')\n+                ->screenshot(1);\n+            $borrowings = Borrowing::Join('users', 'borrowings.user_id', '=', 'users.id')\n+                ->Join('books', 'borrowings.book_id', '=', 'books.id')\n+                ->orderBy('users.email', 'asc')\n+                ->limit(10)->get();\n+\n+            $checkEmail = false;\n+            foreach ($borrowings as $index => $borrowing) {\n+                $borrowingEmail = $browser->text('#table-borrowings tbody tr:nth-child(' . (string)($index + 1) . ') td:nth-child(3)');\n+                $checkEmail = $borrowing->users->email == $borrowingEmail;\n+                if (!$checkEmail) {\n+                    break;\n+                }\n+            }\n+            $this->assertTrue($checkEmail);\n+        });\n+    }\n+\n+    /**\n+     * Test sort DESC Email\n+     *\n+     * @return void\n+     */\n+    public function testSortEmailDESC()\n+    {\n+        $this->makeUser();\n+        $this->makeborrowings(16);\n+        $this->browse(function (Browser $browser) {\n+            $browser->loginAs(User::find(1))\n+                ->resize(900, 1600)\n+                ->visit('/admin/borrowings/')\n+                ->clickLink('Email')\n+                ->clickLink('Email')\n+                ->assertVisible('.fa.fa-sort-desc')\n+                ->screenshot(1);\n+            $borrowings = Borrowing::Join('users', 'borrowings.user_id', '=', 'users.id')\n+                ->Join('books', 'borrowings.book_id', '=', 'books.id')\n+                ->orderBy('email', 'desc')\n+                ->limit(10)->get();\n+\n+            $checkEmail = false;\n+            foreach ($borrowings as $index => $borrowing) {\n+                $borrowingEmail = $browser->text('#table-borrowings tbody tr:nth-child(' . (string)($index + 1) . ') td:nth-child(3)');\n+                $checkEmail = $borrowing->email == $borrowingEmail;\n+                if (!$checkEmail) {\n+                    break;\n+                }\n+            }\n+            $this->assertTrue($checkEmail);\n+        });\n+    }\n+\n+    /**\n+     * Test sort DESC Email has pagination\n+     *\n+     * @return void\n+     */\n+    public function testSortEmailDESCWithPagination()\n+    {\n+        $this->makeUser();\n+        $this->makeborrowings(14);\n+        $this->browse(function (Browser $browser) {\n+            $page = $browser->loginAs(User::find(1))\n+                ->resize(900, 1600)\n+                ->visit('/admin/borrowings?sort=users.email&order=desc&page=2')\n+                ->assertVisible('.fa.fa-sort-desc')\n+                ->screenshot(1);\n+            $elements = $page->elements('#table-borrowings tbody tr');\n+            $this->assertCount(5, $elements);\n+            $borrowings = Borrowing::Join('users', 'borrowings.user_id', '=', 'users.id')\n+                ->Join('books', 'borrowings.book_id', '=', 'books.id')\n+                ->orderBy('email', 'desc')\n+                ->skip(10)->take(5)->get();\n+\n+            $checkEmail = false;\n+            foreach ($borrowings as $index => $borrowing) {\n+                $borrowingEmail = $browser->text('#table-borrowings tbody tr:nth-child(' . (string)($index + 1) . ') td:nth-child(3)');\n+                $checkEmail = $borrowing->email == $borrowingEmail;\n+                if (!$checkEmail) {\n+                    break;\n+                }\n+            }\n+            $this->assertTrue($checkEmail);\n+        });\n+    }\n+\n+    /**\n+     * Test sort ASC Email has pagination\n+     *\n+     * @return void\n+     */\n+    public function testSortEmailASCWithPagination()\n+    {\n+        $this->makeUser();\n+        $this->makeborrowings(14);\n+        $this->browse(function (Browser $browser) {\n+            $page = $browser->loginAs(User::find(1))\n+                ->resize(900, 1600)\n+                ->visit('/admin/borrowings?sort=users.email&order=asc&page=2')\n+                ->assertVisible('.fa.fa-sort-asc')\n+                ->screenshot(1);\n+            $elements = $page->elements('#table-borrowings tbody tr');\n+            $this->assertCount(5, $elements);\n+            $borrowings = Borrowing::Join('users', 'borrowings.user_id', '=', 'users.id')\n+                ->Join('books', 'borrowings.book_id', '=', 'books.id')\n+                ->orderBy('email', 'asc')\n+                ->skip(10)->take(5)->get();\n+\n+            $checkEmail = false;\n+            foreach ($borrowings as $index => $borrowing) {\n+                $borrowingEmail = $browser->text('#table-borrowings tbody tr:nth-child(' . (string)($index + 1) . ') td:nth-child(3)');\n+                $checkEmail = $borrowing->email == $borrowingEmail;\n+                if (!$checkEmail) {\n+                    break;\n+                }\n+            }\n+            $this->assertTrue($checkEmail);\n+        });\n+    }\n+\n+    /**\n+     * Test sort ASC Book\n+     *\n+     * @return void\n+     */\n+    public function testSortBookASC()\n+    {\n+        $this->makeUser();\n+        $this->makeborrowings(16);\n+        $this->browse(function (Browser $browser) {\n+            $browser->loginAs(User::find(1))\n+                ->visit('/admin/borrowings/')\n+                ->resize(900, 1600)\n+                ->clickLink('Book')\n+                ->assertVisible('.fa.fa-sort-asc')\n+                ->screenshot(1);\n+            $borrowings = Borrowing::Join('users', 'borrowings.user_id', '=', 'users.id')\n+                ->Join('books', 'borrowings.book_id', '=', 'books.id')\n+                ->orderBy('books.name', 'asc')\n+                ->limit(10)->get();\n+\n+            $checkBook = false;\n+            foreach ($borrowings as $index => $borrowing) {\n+                $borrowingBook = $browser->text('#table-borrowings tbody tr:nth-child(' . (string)($index + 1) . ') td:nth-child(4)');\n+                $checkBook = $borrowing->books->name == $borrowingBook;\n+                if (!$checkBook) {\n+                    break;\n+                }\n+            }\n+            $this->assertTrue($checkBook);\n+        });\n+    }\n+\n+    /**\n+     * Test sort DESC Book\n+     *\n+     * @return void\n+     */\n+    public function testSortBookDESC()\n+    {\n+        $this->makeUser();\n+        $this->makeborrowings(16);\n+        $this->browse(function (Browser $browser) {\n+            $browser->loginAs(User::find(1))\n+                ->visit('/admin/borrowings/')\n+                ->resize(900, 1600)\n+                ->clickLink('Book')\n+                ->clickLink('Book')\n+                ->assertVisible('.fa.fa-sort-desc')\n+                ->screenshot(1);\n+            $borrowings = Borrowing::Join('users', 'borrowings.user_id', '=', 'users.id')\n+                ->Join('books', 'borrowings.book_id', '=', 'books.id')\n+                ->orderBy('books.name', 'desc')\n+                ->limit(10)->get();\n+\n+            $checkBook = false;\n+            foreach ($borrowings as $index => $borrowing) {\n+                $borrowingBook = $browser->text('#table-borrowings tbody tr:nth-child(' . (string)($index + 1) . ') td:nth-child(4)');\n+                $checkBook = $borrowing->books->name == $borrowingBook;\n+                if (!$checkBook) {\n+                    break;\n+                }\n+            }\n+            $this->assertTrue($checkBook);\n+        });\n+    }\n+\n+    /**\n+     * Test sort DESC Book has pagination\n+     *\n+     * @return void\n+     */\n+    public function testSortBookDESCWithPagination()\n+    {\n+        $this->makeUser();\n+        $this->makeborrowings(14);\n+        $this->browse(function (Browser $browser) {\n+            $page = $browser->loginAs(User::find(1))\n+                            ->visit('/admin/borrowings?sort=books.name&order=desc&page=2')\n+                            ->resize(900, 1600)\n+                            ->assertVisible('.fa.fa-sort-desc')\n+                            ->screenshot(1);\n+            $elements = $page->elements('#table-borrowings tbody tr');\n+            $this->assertCount(5, $elements);\n+            $borrowings = Borrowing::Join('users', 'borrowings.user_id', '=', 'users.id')\n+                ->Join('books', 'borrowings.book_id', '=', 'books.id')\n+                ->orderBy('books.name', 'desc')\n+                ->skip(10)->take(5)->get();\n+\n+            $checkBook = false;\n+            foreach ($borrowings as $index => $borrowing) {\n+                $borrowingBook = $browser->text('#table-borrowings tbody tr:nth-child(' . (string)($index + 1) . ') td:nth-child(4)');\n+                $checkBook = $borrowing->books->name == $borrowingBook;\n+                if (!$checkBook) {\n+                    break;\n+                }\n+            }\n+            $this->assertTrue($checkBook);\n+        });\n+    }\n+\n+    /**\n+     * Test sort ASC Book has pagination\n+     *\n+     * @return void\n+     */\n+    public function testSortBookASCWithPagination()\n+    {\n+        $this->makeUser();\n+        $this->makeborrowings(14);\n+        $this->browse(function (Browser $browser) {\n+            $page = $browser->loginAs(User::find(1))\n+                            ->visit('/admin/borrowings?sort=books.name&order=asc&page=2')\n+                            ->resize(900, 1600)\n+                            ->assertVisible('.fa.fa-sort-asc')\n+                            ->screenshot(1);\n+            $elements = $page->elements('#table-borrowings tbody tr');\n+            $this->assertCount(5, $elements);\n+            $borrowings = Borrowing::Join('users', 'borrowings.user_id', '=', 'users.id')\n+                ->Join('books', 'borrowings.book_id', '=', 'books.id')\n+                ->orderBy('books.name', 'asc')\n+                ->skip(10)->take(5)->get();\n+\n+            $checkBook = false;\n+            foreach ($borrowings as $index => $borrowing) {\n+                $borrowingBook = $browser->text('#table-borrowings tbody tr:nth-child(' . (string)($index + 1) . ') td:nth-child(4)');\n+                $checkBook = $borrowing->books->name == $borrowingBook;\n+                if (!$checkBook) {\n+                    break;\n+                }\n+            }\n+            $this->assertTrue($checkBook);\n+        });\n+    }\n+\n+    /**\n+     * Test sort ASC FromDate\n+     *\n+     * @return void\n+     */\n+    public function testSortFromDateASC()\n+    {\n+\n+        $this->makeUser();\n+        $this->makeborrowings(16);\n+        $this->browse(function (Browser $browser) {\n+            $browser->loginAs(User::find(1))\n+                ->visit('/admin/borrowings/')\n+                ->resize(900, 1600)\n+                ->clickLink('From date')\n+                ->assertVisible('.fa.fa-sort-asc')\n+                ->screenshot(1);\n+            $borrowings = Borrowing::Join('users', 'borrowings.user_id', '=', 'users.id')\n+                ->Join('books', 'borrowings.book_id', '=', 'books.id')\n+                ->orderBy('from_date', 'asc')\n+                ->limit(10)->get();\n+\n+            $checkFromDate = false;\n+            foreach ($borrowings as $index => $borrowing) {\n+                $borrowingFromDate = $browser->text('#table-borrowings tbody tr:nth-child(' . (string)($index + 1) . ') td:nth-child(5)');\n+                $checkFromDate = Carbon::parse($borrowing->from_date)->format('d-m-Y') == $borrowingFromDate;\n+                if (!$checkFromDate) {\n+                    break;\n+                }\n+            }\n+            $this->assertTrue($checkFromDate);\n+        });\n+    }\n+\n+    /**\n+     * Test sort DESC FromDate\n+     *\n+     * @return void\n+     */\n+    public function testSortFromDateDESC()\n+    {\n+        $this->makeUser();\n+        $this->makeborrowings(16);\n+        $this->browse(function (Browser $browser) {\n+            $browser->loginAs(User::find(1))\n+                ->visit('/admin/borrowings/')\n+                ->resize(900, 1600)\n+                ->clickLink('From date')\n+                ->clickLink('From date')\n+                ->assertVisible('.fa.fa-sort-desc')\n+                ->screenshot(1);\n+            $borrowings = Borrowing::Join('users', 'borrowings.user_id', '=', 'users.id')\n+                ->Join('books', 'borrowings.book_id', '=', 'books.id')\n+                ->orderBy('from_date', 'desc')\n+                ->limit(10)->get();\n+\n+            $checkFromDate = false;\n+            foreach ($borrowings as $index => $borrowing) {\n+                $borrowingFromDate = $browser->text('#table-borrowings tbody tr:nth-child(' . (string)($index + 1) . ') td:nth-child(5)');\n+                $checkFromDate = Carbon::parse($borrowing->from_date)->format('d-m-Y') == $borrowingFromDate;\n+                if (!$checkFromDate) {\n+                    break;\n+                }\n+            }\n+            $this->assertTrue($checkFromDate);\n+        });\n+    }\n+\n+    /**\n+     * Test sort DESC FromDate has pagination\n+     *\n+     * @return void\n+     */\n+    public function testSortFromDateDESCWithPaginaiton()\n+    {\n+        $this->makeUser();","path":"tests/Browser/Pages/Books/SortBorrowingsTest.php","position":679,"original_position":679,"commit_id":"9553068e9fecd5699cc3d253235da0d17003054e","original_commit_id":"9553068e9fecd5699cc3d253235da0d17003054e","user":{"login":"at-luanle","id":33856992,"avatar_url":"https://avatars2.githubusercontent.com/u/33856992?v=4","gravatar_id":"","url":"https://api.github.com/users/at-luanle","html_url":"https://github.com/at-luanle","followers_url":"https://api.github.com/users/at-luanle/followers","following_url":"https://api.github.com/users/at-luanle/following{/other_user}","gists_url":"https://api.github.com/users/at-luanle/gists{/gist_id}","starred_url":"https://api.github.com/users/at-luanle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/at-luanle/subscriptions","organizations_url":"https://api.github.com/users/at-luanle/orgs","repos_url":"https://api.github.com/users/at-luanle/repos","events_url":"https://api.github.com/users/at-luanle/events{/privacy}","received_events_url":"https://api.github.com/users/at-luanle/received_events","type":"User","site_admin":false},"body":"nên làm setup giống trên","created_at":"2018-02-01T02:51:36Z","updated_at":"2018-02-01T02:54:17Z","html_url":"https://github.com/AT-PHPIntership/book-library/pull/146#discussion_r165248088","pull_request_url":"https://api.github.com/repos/AT-PHPIntership/book-library/pulls/146","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/AT-PHPIntership/book-library/pulls/comments/165248088"},"html":{"href":"https://github.com/AT-PHPIntership/book-library/pull/146#discussion_r165248088"},"pull_request":{"href":"https://api.github.com/repos/AT-PHPIntership/book-library/pulls/146"}}},"pull_request":{"url":"https://api.github.com/repos/AT-PHPIntership/book-library/pulls/146","id":166424557,"html_url":"https://github.com/AT-PHPIntership/book-library/pull/146","diff_url":"https://github.com/AT-PHPIntership/book-library/pull/146.diff","patch_url":"https://github.com/AT-PHPIntership/book-library/pull/146.patch","issue_url":"https://api.github.com/repos/AT-PHPIntership/book-library/issues/146","number":146,"state":"open","locked":false,"title":"Borrowings sort funtion test","user":{"login":"at-phutran2","id":28639251,"avatar_url":"https://avatars1.githubusercontent.com/u/28639251?v=4","gravatar_id":"","url":"https://api.github.com/users/at-phutran2","html_url":"https://github.com/at-phutran2","followers_url":"https://api.github.com/users/at-phutran2/followers","following_url":"https://api.github.com/users/at-phutran2/following{/other_user}","gists_url":"https://api.github.com/users/at-phutran2/gists{/gist_id}","starred_url":"https://api.github.com/users/at-phutran2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/at-phutran2/subscriptions","organizations_url":"https://api.github.com/users/at-phutran2/orgs","repos_url":"https://api.github.com/users/at-phutran2/repos","events_url":"https://api.github.com/users/at-phutran2/events{/privacy}","received_events_url":"https://api.github.com/users/at-phutran2/received_events","type":"User","site_admin":false},"body":"## Description\r\nunittest for sort funtion borrowing list!\r\n\r\n## Reference Requirements\r\n- Product Backlog ID: #3.6\r\n- Task ID: #PBI-3\r\n\r\n## Migrations\r\nNO\r\n\r\n## Impacted Areas in Application\r\nList general components of the application that this PR will affect:\r\n\r\n- resources/views/backend/books/borrow.blade.php\r\n- tests/Browser/Pages/Books/SortBookTest.php\r\n- tests/Browser/Pages/Books/SortBorrowingsTest.php\r\n\r\n","created_at":"2018-02-01T01:53:50Z","updated_at":"2018-02-01T02:54:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3fe29e0d7e30989ef5679d42e7e74dcd4cb4d4f0","assignee":{"login":"at-tamnguyen4","id":33854539,"avatar_url":"https://avatars0.githubusercontent.com/u/33854539?v=4","gravatar_id":"","url":"https://api.github.com/users/at-tamnguyen4","html_url":"https://github.com/at-tamnguyen4","followers_url":"https://api.github.com/users/at-tamnguyen4/followers","following_url":"https://api.github.com/users/at-tamnguyen4/following{/other_user}","gists_url":"https://api.github.com/users/at-tamnguyen4/gists{/gist_id}","starred_url":"https://api.github.com/users/at-tamnguyen4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/at-tamnguyen4/subscriptions","organizations_url":"https://api.github.com/users/at-tamnguyen4/orgs","repos_url":"https://api.github.com/users/at-tamnguyen4/repos","events_url":"https://api.github.com/users/at-tamnguyen4/events{/privacy}","received_events_url":"https://api.github.com/users/at-tamnguyen4/received_events","type":"User","site_admin":false},"assignees":[{"login":"at-tamnguyen4","id":33854539,"avatar_url":"https://avatars0.githubusercontent.com/u/33854539?v=4","gravatar_id":"","url":"https://api.github.com/users/at-tamnguyen4","html_url":"https://github.com/at-tamnguyen4","followers_url":"https://api.github.com/users/at-tamnguyen4/followers","following_url":"https://api.github.com/users/at-tamnguyen4/following{/other_user}","gists_url":"https://api.github.com/users/at-tamnguyen4/gists{/gist_id}","starred_url":"https://api.github.com/users/at-tamnguyen4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/at-tamnguyen4/subscriptions","organizations_url":"https://api.github.com/users/at-tamnguyen4/orgs","repos_url":"https://api.github.com/users/at-tamnguyen4/repos","events_url":"https://api.github.com/users/at-tamnguyen4/events{/privacy}","received_events_url":"https://api.github.com/users/at-tamnguyen4/received_events","type":"User","site_admin":false},{"login":"at-luanle","id":33856992,"avatar_url":"https://avatars2.githubusercontent.com/u/33856992?v=4","gravatar_id":"","url":"https://api.github.com/users/at-luanle","html_url":"https://github.com/at-luanle","followers_url":"https://api.github.com/users/at-luanle/followers","following_url":"https://api.github.com/users/at-luanle/following{/other_user}","gists_url":"https://api.github.com/users/at-luanle/gists{/gist_id}","starred_url":"https://api.github.com/users/at-luanle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/at-luanle/subscriptions","organizations_url":"https://api.github.com/users/at-luanle/orgs","repos_url":"https://api.github.com/users/at-luanle/repos","events_url":"https://api.github.com/users/at-luanle/events{/privacy}","received_events_url":"https://api.github.com/users/at-luanle/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"milestone":null,"commits_url":"https://api.github.com/repos/AT-PHPIntership/book-library/pulls/146/commits","review_comments_url":"https://api.github.com/repos/AT-PHPIntership/book-library/pulls/146/comments","review_comment_url":"https://api.github.com/repos/AT-PHPIntership/book-library/pulls/comments{/number}","comments_url":"https://api.github.com/repos/AT-PHPIntership/book-library/issues/146/comments","statuses_url":"https://api.github.com/repos/AT-PHPIntership/book-library/statuses/9553068e9fecd5699cc3d253235da0d17003054e","head":{"label":"AT-PHPIntership:borrowings_sort_funtion_test","ref":"borrowings_sort_funtion_test","sha":"9553068e9fecd5699cc3d253235da0d17003054e","user":{"login":"AT-PHPIntership","id":17865237,"avatar_url":"https://avatars1.githubusercontent.com/u/17865237?v=4","gravatar_id":"","url":"https://api.github.com/users/AT-PHPIntership","html_url":"https://github.com/AT-PHPIntership","followers_url":"https://api.github.com/users/AT-PHPIntership/followers","following_url":"https://api.github.com/users/AT-PHPIntership/following{/other_user}","gists_url":"https://api.github.com/users/AT-PHPIntership/gists{/gist_id}","starred_url":"https://api.github.com/users/AT-PHPIntership/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AT-PHPIntership/subscriptions","organizations_url":"https://api.github.com/users/AT-PHPIntership/orgs","repos_url":"https://api.github.com/users/AT-PHPIntership/repos","events_url":"https://api.github.com/users/AT-PHPIntership/events{/privacy}","received_events_url":"https://api.github.com/users/AT-PHPIntership/received_events","type":"Organization","site_admin":false},"repo":{"id":115322121,"name":"book-library","full_name":"AT-PHPIntership/book-library","owner":{"login":"AT-PHPIntership","id":17865237,"avatar_url":"https://avatars1.githubusercontent.com/u/17865237?v=4","gravatar_id":"","url":"https://api.github.com/users/AT-PHPIntership","html_url":"https://github.com/AT-PHPIntership","followers_url":"https://api.github.com/users/AT-PHPIntership/followers","following_url":"https://api.github.com/users/AT-PHPIntership/following{/other_user}","gists_url":"https://api.github.com/users/AT-PHPIntership/gists{/gist_id}","starred_url":"https://api.github.com/users/AT-PHPIntership/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AT-PHPIntership/subscriptions","organizations_url":"https://api.github.com/users/AT-PHPIntership/orgs","repos_url":"https://api.github.com/users/AT-PHPIntership/repos","events_url":"https://api.github.com/users/AT-PHPIntership/events{/privacy}","received_events_url":"https://api.github.com/users/AT-PHPIntership/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/AT-PHPIntership/book-library","description":null,"fork":false,"url":"https://api.github.com/repos/AT-PHPIntership/book-library","forks_url":"https://api.github.com/repos/AT-PHPIntership/book-library/forks","keys_url":"https://api.github.com/repos/AT-PHPIntership/book-library/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AT-PHPIntership/book-library/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AT-PHPIntership/book-library/teams","hooks_url":"https://api.github.com/repos/AT-PHPIntership/book-library/hooks","issue_events_url":"https://api.github.com/repos/AT-PHPIntership/book-library/issues/events{/number}","events_url":"https://api.github.com/repos/AT-PHPIntership/book-library/events","assignees_url":"https://api.github.com/repos/AT-PHPIntership/book-library/assignees{/user}","branches_url":"https://api.github.com/repos/AT-PHPIntership/book-library/branches{/branch}","tags_url":"https://api.github.com/repos/AT-PHPIntership/book-library/tags","blobs_url":"https://api.github.com/repos/AT-PHPIntership/book-library/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AT-PHPIntership/book-library/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AT-PHPIntership/book-library/git/refs{/sha}","trees_url":"https://api.github.com/repos/AT-PHPIntership/book-library/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AT-PHPIntership/book-library/statuses/{sha}","languages_url":"https://api.github.com/repos/AT-PHPIntership/book-library/languages","stargazers_url":"https://api.github.com/repos/AT-PHPIntership/book-library/stargazers","contributors_url":"https://api.github.com/repos/AT-PHPIntership/book-library/contributors","subscribers_url":"https://api.github.com/repos/AT-PHPIntership/book-library/subscribers","subscription_url":"https://api.github.com/repos/AT-PHPIntership/book-library/subscription","commits_url":"https://api.github.com/repos/AT-PHPIntership/book-library/commits{/sha}","git_commits_url":"https://api.github.com/repos/AT-PHPIntership/book-library/git/commits{/sha}","comments_url":"https://api.github.com/repos/AT-PHPIntership/book-library/comments{/number}","issue_comment_url":"https://api.github.com/repos/AT-PHPIntership/book-library/issues/comments{/number}","contents_url":"https://api.github.com/repos/AT-PHPIntership/book-library/contents/{+path}","compare_url":"https://api.github.com/repos/AT-PHPIntership/book-library/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AT-PHPIntership/book-library/merges","archive_url":"https://api.github.com/repos/AT-PHPIntership/book-library/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AT-PHPIntership/book-library/downloads","issues_url":"https://api.github.com/repos/AT-PHPIntership/book-library/issues{/number}","pulls_url":"https://api.github.com/repos/AT-PHPIntership/book-library/pulls{/number}","milestones_url":"https://api.github.com/repos/AT-PHPIntership/book-library/milestones{/number}","notifications_url":"https://api.github.com/repos/AT-PHPIntership/book-library/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AT-PHPIntership/book-library/labels{/name}","releases_url":"https://api.github.com/repos/AT-PHPIntership/book-library/releases{/id}","deployments_url":"https://api.github.com/repos/AT-PHPIntership/book-library/deployments","created_at":"2017-12-25T08:40:48Z","updated_at":"2017-12-25T08:42:31Z","pushed_at":"2018-02-01T02:50:47Z","git_url":"git://github.com/AT-PHPIntership/book-library.git","ssh_url":"git@github.com:AT-PHPIntership/book-library.git","clone_url":"https://github.com/AT-PHPIntership/book-library.git","svn_url":"https://github.com/AT-PHPIntership/book-library","homepage":null,"size":7563,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":10,"license":null,"forks":0,"open_issues":10,"watchers":0,"default_branch":"master"}},"base":{"label":"AT-PHPIntership:master","ref":"master","sha":"2bb4e1ccf92cb7a45a67a5a976355e3db8866c0b","user":{"login":"AT-PHPIntership","id":17865237,"avatar_url":"https://avatars1.githubusercontent.com/u/17865237?v=4","gravatar_id":"","url":"https://api.github.com/users/AT-PHPIntership","html_url":"https://github.com/AT-PHPIntership","followers_url":"https://api.github.com/users/AT-PHPIntership/followers","following_url":"https://api.github.com/users/AT-PHPIntership/following{/other_user}","gists_url":"https://api.github.com/users/AT-PHPIntership/gists{/gist_id}","starred_url":"https://api.github.com/users/AT-PHPIntership/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AT-PHPIntership/subscriptions","organizations_url":"https://api.github.com/users/AT-PHPIntership/orgs","repos_url":"https://api.github.com/users/AT-PHPIntership/repos","events_url":"https://api.github.com/users/AT-PHPIntership/events{/privacy}","received_events_url":"https://api.github.com/users/AT-PHPIntership/received_events","type":"Organization","site_admin":false},"repo":{"id":115322121,"name":"book-library","full_name":"AT-PHPIntership/book-library","owner":{"login":"AT-PHPIntership","id":17865237,"avatar_url":"https://avatars1.githubusercontent.com/u/17865237?v=4","gravatar_id":"","url":"https://api.github.com/users/AT-PHPIntership","html_url":"https://github.com/AT-PHPIntership","followers_url":"https://api.github.com/users/AT-PHPIntership/followers","following_url":"https://api.github.com/users/AT-PHPIntership/following{/other_user}","gists_url":"https://api.github.com/users/AT-PHPIntership/gists{/gist_id}","starred_url":"https://api.github.com/users/AT-PHPIntership/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AT-PHPIntership/subscriptions","organizations_url":"https://api.github.com/users/AT-PHPIntership/orgs","repos_url":"https://api.github.com/users/AT-PHPIntership/repos","events_url":"https://api.github.com/users/AT-PHPIntership/events{/privacy}","received_events_url":"https://api.github.com/users/AT-PHPIntership/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/AT-PHPIntership/book-library","description":null,"fork":false,"url":"https://api.github.com/repos/AT-PHPIntership/book-library","forks_url":"https://api.github.com/repos/AT-PHPIntership/book-library/forks","keys_url":"https://api.github.com/repos/AT-PHPIntership/book-library/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AT-PHPIntership/book-library/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AT-PHPIntership/book-library/teams","hooks_url":"https://api.github.com/repos/AT-PHPIntership/book-library/hooks","issue_events_url":"https://api.github.com/repos/AT-PHPIntership/book-library/issues/events{/number}","events_url":"https://api.github.com/repos/AT-PHPIntership/book-library/events","assignees_url":"https://api.github.com/repos/AT-PHPIntership/book-library/assignees{/user}","branches_url":"https://api.github.com/repos/AT-PHPIntership/book-library/branches{/branch}","tags_url":"https://api.github.com/repos/AT-PHPIntership/book-library/tags","blobs_url":"https://api.github.com/repos/AT-PHPIntership/book-library/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AT-PHPIntership/book-library/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AT-PHPIntership/book-library/git/refs{/sha}","trees_url":"https://api.github.com/repos/AT-PHPIntership/book-library/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AT-PHPIntership/book-library/statuses/{sha}","languages_url":"https://api.github.com/repos/AT-PHPIntership/book-library/languages","stargazers_url":"https://api.github.com/repos/AT-PHPIntership/book-library/stargazers","contributors_url":"https://api.github.com/repos/AT-PHPIntership/book-library/contributors","subscribers_url":"https://api.github.com/repos/AT-PHPIntership/book-library/subscribers","subscription_url":"https://api.github.com/repos/AT-PHPIntership/book-library/subscription","commits_url":"https://api.github.com/repos/AT-PHPIntership/book-library/commits{/sha}","git_commits_url":"https://api.github.com/repos/AT-PHPIntership/book-library/git/commits{/sha}","comments_url":"https://api.github.com/repos/AT-PHPIntership/book-library/comments{/number}","issue_comment_url":"https://api.github.com/repos/AT-PHPIntership/book-library/issues/comments{/number}","contents_url":"https://api.github.com/repos/AT-PHPIntership/book-library/contents/{+path}","compare_url":"https://api.github.com/repos/AT-PHPIntership/book-library/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AT-PHPIntership/book-library/merges","archive_url":"https://api.github.com/repos/AT-PHPIntership/book-library/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AT-PHPIntership/book-library/downloads","issues_url":"https://api.github.com/repos/AT-PHPIntership/book-library/issues{/number}","pulls_url":"https://api.github.com/repos/AT-PHPIntership/book-library/pulls{/number}","milestones_url":"https://api.github.com/repos/AT-PHPIntership/book-library/milestones{/number}","notifications_url":"https://api.github.com/repos/AT-PHPIntership/book-library/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AT-PHPIntership/book-library/labels{/name}","releases_url":"https://api.github.com/repos/AT-PHPIntership/book-library/releases{/id}","deployments_url":"https://api.github.com/repos/AT-PHPIntership/book-library/deployments","created_at":"2017-12-25T08:40:48Z","updated_at":"2017-12-25T08:42:31Z","pushed_at":"2018-02-01T02:50:47Z","git_url":"git://github.com/AT-PHPIntership/book-library.git","ssh_url":"git@github.com:AT-PHPIntership/book-library.git","clone_url":"https://github.com/AT-PHPIntership/book-library.git","svn_url":"https://github.com/AT-PHPIntership/book-library","homepage":null,"size":7563,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":10,"license":null,"forks":0,"open_issues":10,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/AT-PHPIntership/book-library/pulls/146"},"html":{"href":"https://github.com/AT-PHPIntership/book-library/pull/146"},"issue":{"href":"https://api.github.com/repos/AT-PHPIntership/book-library/issues/146"},"comments":{"href":"https://api.github.com/repos/AT-PHPIntership/book-library/issues/146/comments"},"review_comments":{"href":"https://api.github.com/repos/AT-PHPIntership/book-library/pulls/146/comments"},"review_comment":{"href":"https://api.github.com/repos/AT-PHPIntership/book-library/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/AT-PHPIntership/book-library/pulls/146/commits"},"statuses":{"href":"https://api.github.com/repos/AT-PHPIntership/book-library/statuses/9553068e9fecd5699cc3d253235da0d17003054e"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"at-luanle"}}