Initial commit
This commit is contained in:
46
scripts/test-balance-visibility.php
Executable file
46
scripts/test-balance-visibility.php
Executable file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Account;
|
||||
|
||||
// Set TIMEBANK_CONFIG to timebank-default
|
||||
putenv('TIMEBANK_CONFIG=timebank-default');
|
||||
|
||||
echo "Testing balance visibility with TIMEBANK_CONFIG=timebank-default\n";
|
||||
echo "======================================================================\n\n";
|
||||
|
||||
// Test 1: Check config values
|
||||
echo "1. Configuration values:\n";
|
||||
echo " - balance_public (user): " . (timebank_config('account_info.user.balance_public') ? 'true' : 'false') . "\n";
|
||||
echo " - sumBalances_public (user): " . (timebank_config('account_info.user.sumBalances_public') ? 'true' : 'false') . "\n\n";
|
||||
|
||||
// Test 2: Get a test user
|
||||
$testUser = User::where('name', '!=', 'Super User')->first();
|
||||
if (!$testUser) {
|
||||
echo "No test user found!\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo "2. Test user: {$testUser->name} (ID: {$testUser->id})\n\n";
|
||||
|
||||
// Test 3: Get account totals without authentication
|
||||
echo "3. Getting account totals (not logged in):\n";
|
||||
$account = new Account();
|
||||
$totals = $account->getAccountsTotals(get_class($testUser), $testUser->id, 365);
|
||||
|
||||
echo " - sumBalances: ";
|
||||
if ($totals['sumBalances'] === null) {
|
||||
echo "NULL (hidden as expected)\n";
|
||||
} else {
|
||||
echo $totals['sumBalances'] . " (VISIBLE - this is the bug!)\n";
|
||||
}
|
||||
|
||||
echo "\n4. Testing getCanManageAccounts():\n";
|
||||
echo " - Result: " . ($account->getCanManageAccounts() ? 'true' : 'false') . "\n";
|
||||
|
||||
echo "\nDone!\n";
|
||||
Reference in New Issue
Block a user