Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b6d1e6c
Update admin retrieval logic to use is_administrator
sanjacornelius Feb 13, 2024
f875013
Merge branch 'fix-failing-script-executor-test' into observation/FOUR…
sanjacornelius Feb 14, 2024
7c799a2
Merge branch 'next' into observation/FOUR-14152
sanjacornelius Feb 14, 2024
3284ae6
Seed Admin User in test database
sanjacornelius Feb 14, 2024
332da14
Create Admin User Seeder for PHPUnit Tests
sanjacornelius Feb 15, 2024
e6e2343
Remove unused 'user' variable
sanjacornelius Feb 15, 2024
b68f58c
SonarQube fixes
sanjacornelius Feb 15, 2024
da74dfe
Remove creation and deletion of admin user in test
sanjacornelius Feb 15, 2024
cffacad
Trigger PR
sanjacornelius Feb 15, 2024
6351e5d
Merge branch 'next' into observation/FOUR-14152-B
sanjacornelius Feb 15, 2024
2d0a9fb
Testing CICD
sanjacornelius Feb 15, 2024
fe63ec5
Seed the AdminTestUserSeeder when adding GlobalSignalProcesses
sanjacornelius Feb 16, 2024
2412cc4
Update base test case to create test admin user
sanjacornelius Feb 16, 2024
242cee9
Add missing User Model
sanjacornelius Feb 16, 2024
c37dda9
trigger PR
sanjacornelius Feb 16, 2024
37c29a4
resolve missing Hash class
sanjacornelius Feb 16, 2024
0789b63
Configure personal access client
sanjacornelius Feb 16, 2024
6fa981b
Remove test admin user
sanjacornelius Feb 16, 2024
c908d03
Create admin user for each test using the import/export helper trait
sanjacornelius Feb 16, 2024
06821db
Remove unused code
sanjacornelius Feb 16, 2024
dbe871a
Remove AdminTestUserSeeder reference
sanjacornelius Feb 16, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function export() : void
public function import() : bool
{
$authenticatedUser = Auth::user();
$userId = $authenticatedUser ? $authenticatedUser->id : User::where('username', 'admin')->pluck('id');
$userId = $authenticatedUser ? $authenticatedUser->id : User::where('is_administrator', true)->first()->id;
switch ($this->mode) {
case 'copy':
case 'new':
Expand Down
9 changes: 9 additions & 0 deletions tests/Feature/ImportExport/Exporters/ProcessExporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ class ProcessExporterTest extends TestCase
{
use HelperTrait;

/**
* Init admin user
*/
protected function setUp(): void
{
parent::setUp();
$this->createAdminUser();
}

private function fixtures()
{
// Create simple screens. Extensive screen tests are in ScreenExporterTest.php
Expand Down
9 changes: 9 additions & 0 deletions tests/Feature/ImportExport/Exporters/ScreenExporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ class ScreenExporterTest extends TestCase
{
use HelperTrait;

/**
* Init admin user
*/
protected function setUp(): void
{
parent::setUp();
$this->createAdminUser();
}

private function fixtures()
{
$screen = $this->createScreen('screen_with_nested_screen', ['title' => 'screen'], 'watchers');
Expand Down
12 changes: 10 additions & 2 deletions tests/Feature/ImportExport/Exporters/ScriptExporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ class ScriptExporterTest extends TestCase
{
use HelperTrait;

/**
* Init admin user
*/
protected function setUp(): void
{
parent::setUp();
$this->createAdminUser();
}

public function test()
{
DB::beginTransaction();
Expand Down Expand Up @@ -114,9 +123,9 @@ public function testHiddenUsesParentMode()

public function testNoMatchingRunAsUser()
{
$admin_user = User::factory()->create(['is_administrator' => true]);
DB::beginTransaction();
$user = User::factory()->create(['username' => 'test']);
$admin_user = User::where('is_administrator', true)->first();
$script = Script::factory()->create(['title' => 'test', 'run_as_user_id' => $user->id]);

$payload = $this->export($script, ScriptExporter::class, null, false);
Expand All @@ -126,7 +135,6 @@ public function testNoMatchingRunAsUser()

$script = Script::where('title', 'test')->firstOrFail();
$this->assertEquals($script->run_as_user_id, $admin_user->id);
$admin_user->delete();
}

public function testRunAsUserIdNull()
Expand Down
6 changes: 6 additions & 0 deletions tests/Feature/ImportExport/HelperTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use ProcessMaker\Models\ProcessCategory;
use ProcessMaker\Models\Screen;
use ProcessMaker\Models\SignalData;
use ProcessMaker\Models\User;

trait HelperTrait
{
Expand Down Expand Up @@ -89,4 +90,9 @@ public function makeOptions($options = [])
json_encode($options)
);
}

public function createAdminUser()
{
User::factory()->create(['is_administrator' => true]);
}
}