mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
Continue implementing tests
This commit is contained in:
parent
a2e47d19fc
commit
89eff23e44
|
@ -52,4 +52,13 @@ class SettingFactory extends Factory
|
|||
'email_domain' => 'test.com',
|
||||
];
|
||||
}
|
||||
|
||||
public function withMultipleFullCompanySupport()
|
||||
{
|
||||
return $this->state(function () {
|
||||
return [
|
||||
'full_multiple_companies_support' => 1,
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Tests\Feature\Api\Users;
|
||||
|
||||
use App\Models\Company;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
@ -37,14 +38,43 @@ class UsersForSelectListTest extends TestCase
|
|||
|
||||
public function testUsersScopedToCompanyWhenMultipleFullCompanySupportEnabled()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
Setting::factory()->withMultipleFullCompanySupport()->create();
|
||||
|
||||
[$jedi, $sith] = Company::factory()->count(2)->create();
|
||||
|
||||
User::factory()
|
||||
->for($sith)
|
||||
->create(['first_name' => 'Darth', 'last_name' => 'Vader']);
|
||||
|
||||
User::factory()
|
||||
->for($jedi)
|
||||
->count(3)
|
||||
->sequence(
|
||||
['first_name' => 'Luke', 'last_name' => 'Skywalker'],
|
||||
['first_name' => 'Obi-Wan', 'last_name' => 'Kenobi'],
|
||||
['first_name' => 'Anakin', 'last_name' => 'Skywalker'],
|
||||
)
|
||||
->create();
|
||||
|
||||
Passport::actingAs($jedi->users->first());
|
||||
$response = $this->getJson(route('api.users.selectlist'));
|
||||
$response->assertOk();
|
||||
|
||||
$results = collect($response->json('results'));
|
||||
|
||||
$this->assertEquals($jedi->users->count(), $results->count());
|
||||
|
||||
$this->assertTrue(
|
||||
$results->pluck('text')->contains(fn($text) => str_contains($text, $jedi->users->first()->first_name))
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
$results->pluck('text')->contains(fn($text) => str_contains($text, $sith->users->first()->first_name))
|
||||
);
|
||||
}
|
||||
|
||||
public function testUsersScopedToCompanyDuringSearchWhenMultipleFullCompanySupportEnabled()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,17 @@
|
|||
|
||||
namespace Tests;
|
||||
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
use CreatesApplication;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->beforeApplicationDestroyed(fn() => Setting::$_cache = null);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue