diff --git a/src/Services/Search/SearchService.php b/src/Services/Search/SearchService.php index 26dc4ada6..ac9bfc676 100644 --- a/src/Services/Search/SearchService.php +++ b/src/Services/Search/SearchService.php @@ -466,7 +466,7 @@ protected function setSummaryOrderBy($column, $wrap_column) { $sort_order = array_get($column->options, 'sort_order'); if (is_nullorempty($sort_order)) { - return $this; + $sort_order = 1; } $sort_type = isMatchString(array_get($column->options, 'sort_type'), '-1') ? 'desc' : 'asc'; diff --git a/tests/Browser/ExmentKitTestCase.php b/tests/Browser/ExmentKitTestCase.php index cd7141555..1746e2c45 100644 --- a/tests/Browser/ExmentKitTestCase.php +++ b/tests/Browser/ExmentKitTestCase.php @@ -59,7 +59,30 @@ protected function setUpTraits() */ protected function login($id = null) { - $this->be(LoginUser::find($id?? 1)); + $targetId = $id ?? 1; + $user = LoginUser::find($targetId); + + if (!$user) { + // Try to create a minimal test user if it doesn't exist + try { + $this->createTestUserIfNeeded($targetId); + $user = LoginUser::find($targetId); + } catch (\Exception $e) { + // If we still can't find or create the user, throw an informative error + throw new \RuntimeException( + "Test user with ID " . $targetId . " not found and could not be created. " . + "Please ensure test data is properly seeded. Error: " . $e->getMessage() + ); + } + } + + if (!$user) { + throw new \RuntimeException( + "Test user with ID " . $targetId . " not found. Please ensure test data is properly seeded." + ); + } + + $this->be($user); } @@ -114,4 +137,26 @@ public function containsSelectOptions($element, array $options, $negate = false) { return $this->assertInPage(new Constraints\ContainsSelectOption($element, $options), $negate); } + /** + * Create a minimal test user if needed + * @param int $id + * @return void + */ + private function createTestUserIfNeeded($id) + { + // Check if we have basic custom tables + $userTable = \Exceedone\Exment\Model\CustomTable::getEloquent('user'); + if (!$userTable) { + // Try to seed again + \Artisan::call('db:seed', [ + '--class' => 'Exceedone\\Exment\\Database\\Seeder\\InstallSeeder', + '--force' => true + ]); + \Artisan::call('db:seed', [ + '--class' => 'Exceedone\\Exment\\Database\\Seeder\\TestDataSeeder', + '--force' => true + ]); + } + } + }