Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Services/Search/SearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
47 changes: 46 additions & 1 deletion tests/Browser/ExmentKitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down Expand Up @@ -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
]);
}
}

}
Loading