Skip to content
Merged
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
16 changes: 11 additions & 5 deletions Modules/Core/Tests/Unit/DateHelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,29 @@
use Illuminate\Support\Carbon;
use Modules\Core\Support\DateHelpers;
use Modules\Core\Tests\AbstractTestCase;
use PHPUnit\Framework\Attributes\Test;

class DateHelpersTest extends AbstractTestCase
{
public function test_format_date_returns_formatted_date()
#[Test]
public function it_format_date_returns_formatted_date(): void
{
$this->markTestIncomplete();

$date = Carbon::create(2025, 7, 14);
$this->assertEquals('2025-07-14', DateHelpers::formatDate($date));
}

public function test_format_date_returns_dash_for_null()
#[Test]
public function it_format_date_returns_dash_for_null(): void
{
$this->markTestIncomplete();

$this->assertEquals('-', DateHelpers::formatDate(null));
}

public function test_format_since_returns_since_for_past_date()
#[Test]
public function it_format_since_returns_since_for_past_date(): void
{
$this->markTestIncomplete();

Expand All @@ -32,7 +36,8 @@ public function test_format_since_returns_since_for_past_date()
$this->assertStringContainsString('ago', $result);
}

public function test_format_since_returns_in_for_future_date()
#[Test]
public function it_format_since_returns_in_for_future_date(): void
{
$this->markTestIncomplete();

Expand All @@ -41,7 +46,8 @@ public function test_format_since_returns_in_for_future_date()
$this->assertStringContainsString('in', $result);
}

public function test_format_since_returns_date_for_large_difference()
#[Test]
public function it_format_since_returns_date_for_large_difference(): void
{
$this->markTestIncomplete();

Expand Down
16 changes: 8 additions & 8 deletions Modules/ReportBuilder/Tests/Feature/BlockCloningTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function setUp(): void
*/
public function it_clones_system_block_on_edit(): void
{
/* Arrange */
/* arrange */
$company = Company::factory()->create();
$user = User::factory()->create();
$user->companies()->attach($company);
Expand All @@ -45,10 +45,10 @@ public function it_clones_system_block_on_edit(): void
$position = new GridPositionDTO();
$position->setX(1)->setY(1)->setWidth(6)->setHeight(4);

/* Act */
/* act */
$clonedBlock = $this->service->cloneSystemBlock($blockType, $newId, $position);

/* Assert */
/* assert */
$this->assertEquals($newId, $clonedBlock->getId());
$this->assertEquals($blockType, $clonedBlock->getType());
$this->assertTrue($clonedBlock->isCloned());
Expand All @@ -61,7 +61,7 @@ public function it_clones_system_block_on_edit(): void
#[Group('crud')]
public function it_identifies_system_templates(): void
{
/* Arrange */
/* arrange */
$company = Company::factory()->create();
$user = User::factory()->create();
$user->companies()->attach($company);
Expand Down Expand Up @@ -91,7 +91,7 @@ public function it_identifies_system_templates(): void
$template->is_system = true;
$template->save();

/* Assert */
/* assert */
$this->assertTrue($template->is_system);
$this->assertTrue($template->isSystem());
}
Expand All @@ -100,7 +100,7 @@ public function it_identifies_system_templates(): void
#[Group('crud')]
public function it_creates_custom_version_with_unique_id(): void
{
/* Arrange */
/* arrange */
$company = Company::factory()->create();
$user = User::factory()->create();
$user->companies()->attach($company);
Expand All @@ -116,11 +116,11 @@ public function it_creates_custom_version_with_unique_id(): void
$position2 = new GridPositionDTO();
$position2->setX(6)->setY(0)->setWidth(6)->setHeight(4);

/* Act */
/* act */
$firstClone = $this->service->cloneSystemBlock($blockType, $firstCloneId, $position1);
$secondClone = $this->service->cloneSystemBlock($blockType, $secondCloneId, $position2);

/* Assert */
/* assert */
$this->assertNotEquals($firstClone->getId(), $secondClone->getId());
$this->assertEquals($firstCloneId, $firstClone->getId());
$this->assertEquals($secondCloneId, $secondClone->getId());
Expand Down
22 changes: 11 additions & 11 deletions Modules/ReportBuilder/Tests/Feature/CreateReportTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected function createCompanyContext(): Company
*/
public function it_creates_report_template_with_valid_blocks(): void
{
/* Arrange */
/* arrange */
$company = $this->createCompanyContext();

$blocks = [
Expand All @@ -77,15 +77,15 @@ public function it_creates_report_template_with_valid_blocks(): void
],
];

/* Act */
/* act */
$template = $this->service->createTemplate(
$company,
'Test Invoice Template',
'invoice',
$blocks
);

/* Assert */
/* assert */
$this->assertDatabaseHas('report_templates', [
'company_id' => $company->id,
'name' => 'Test Invoice Template',
Expand All @@ -103,7 +103,7 @@ public function it_creates_report_template_with_valid_blocks(): void
#[Group('crud')]
public function it_persists_blocks_to_filesystem(): void
{
/* Arrange */
/* arrange */
$company = $this->createCompanyContext();

$blocks = [
Expand All @@ -120,15 +120,15 @@ public function it_persists_blocks_to_filesystem(): void
],
];

/* Act */
/* act */
$_template = $this->service->createTemplate(
$company,
'Test Template',
'invoice',
$blocks
);

/* Assert */
/* assert */
Storage::disk('report_templates')->assertExists(
"{$company->id}/test-template.json"
);
Expand Down Expand Up @@ -162,7 +162,7 @@ public function it_persists_blocks_to_filesystem(): void
*/
public function it_rejects_invalid_block_types(): void
{
/* Arrange */
/* arrange */
$company = $this->createCompanyContext();

$invalidBlocks = [
Expand All @@ -174,7 +174,7 @@ public function it_rejects_invalid_block_types(): void
],
];

/* Act & Assert */
/* act /* Act & Assert */ assert */
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage("must have a 'type'");

Expand All @@ -190,7 +190,7 @@ public function it_rejects_invalid_block_types(): void
#[Group('multi-tenancy')]
public function it_respects_company_tenancy(): void
{
/* Arrange */
/* arrange */
$company1 = $this->createCompanyContext();
$company2 = Company::factory()->create();

Expand All @@ -208,15 +208,15 @@ public function it_respects_company_tenancy(): void
],
];

/* Act */
/* act */
$template = $this->service->createTemplate(
$company1,
'Company 1 Template',
'invoice',
$blocks
);

/* Assert */
/* assert */
$this->assertEquals($company1->id, $template->company_id);
$this->assertNotEquals($company2->id, $template->company_id);

Expand Down
10 changes: 5 additions & 5 deletions Modules/ReportBuilder/Tests/Feature/GridSnapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ protected function setUp(): void
*/
public function it_snaps_position_to_grid(): void
{
/* Arrange */
/* arrange */
$position = new GridPositionDTO();
$position->setX(0)->setY(0)->setWidth(6)->setHeight(4);

/* Act */
/* act */
$snapped = $this->gridSnapper->snap($position);

/* Assert */
/* assert */
$this->assertEquals(0, $snapped->getX());
$this->assertEquals(0, $snapped->getY());
$this->assertEquals(6, $snapped->getWidth());
Expand All @@ -53,7 +53,7 @@ public function it_snaps_position_to_grid(): void
*/
public function it_validates_position_constraints(): void
{
/* Arrange */
/* arrange */
$validPosition = new GridPositionDTO();
$validPosition->setX(0)->setY(0)->setWidth(6)->setHeight(4);

Expand All @@ -63,7 +63,7 @@ public function it_validates_position_constraints(): void
$invalidPositionWidth = new GridPositionDTO();
$invalidPositionWidth->setX(0)->setY(0)->setWidth(0)->setHeight(4);

/* Act & Assert */
/* act /* Act & Assert */ assert */
$this->assertTrue($this->gridSnapper->validate($validPosition));
$this->assertFalse($this->gridSnapper->validate($invalidPositionX));
$this->assertFalse($this->gridSnapper->validate($invalidPositionWidth));
Expand Down
18 changes: 9 additions & 9 deletions Modules/ReportBuilder/Tests/Feature/ReportRenderingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function createCompanyContext(): Company
*/
public function it_renders_template_to_html_with_correct_block_order(): void
{
/* Arrange */
/* arrange */
$company = $this->createCompanyContext();

$blocks = [
Expand Down Expand Up @@ -94,10 +94,10 @@ public function it_renders_template_to_html_with_correct_block_order(): void
'items' => [],
];

/* Act */
/* act */
$html = $this->renderer->render($template, $data);

/* Assert */
/* assert */
$this->assertIsString($html);
$this->assertStringContainsString('Test Company', $html);
}
Expand All @@ -106,7 +106,7 @@ public function it_renders_template_to_html_with_correct_block_order(): void
#[Group('rendering')]
public function it_renders_template_to_pdf(): void
{
/* Arrange */
/* arrange */
$company = $this->createCompanyContext();

$blocks = [
Expand Down Expand Up @@ -136,10 +136,10 @@ public function it_renders_template_to_pdf(): void
],
];

/* Act */
/* act */
$pdf = $this->renderer->renderToPdf($template, $data);

/* Assert */
/* assert */
$this->assertNotNull($pdf);
$this->assertIsString($pdf);
$this->assertStringStartsWith('%PDF-', $pdf);
Expand All @@ -149,7 +149,7 @@ public function it_renders_template_to_pdf(): void
#[Group('rendering')]
public function it_handles_missing_blocks_with_error_log(): void
{
/* Arrange */
/* arrange */
$company = $this->createCompanyContext();

$blocks = [
Expand Down Expand Up @@ -179,14 +179,14 @@ public function it_handles_missing_blocks_with_error_log(): void
],
];

/* Act */
/* act */
Log::shouldReceive('error')
->once()
->with(\Mockery::pattern('/Block handler not found/i'), \Mockery::any());

$html = $this->renderer->render($template, $data);

/* Assert */
/* assert */
$this->assertIsString($html);
}
}
18 changes: 9 additions & 9 deletions Modules/ReportBuilder/Tests/Feature/UpdateReportTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function setUp(): void
*/
public function it_updates_template_blocks(): void
{
/* Arrange */
/* arrange */
$company = Company::factory()->create();
$user = User::factory()->create();
$user->companies()->attach($company);
Expand Down Expand Up @@ -86,10 +86,10 @@ public function it_updates_template_blocks(): void
],
];

/* Act */
/* act */
$this->service->updateTemplate($template, $updatedBlocks);

/* Assert */
/* assert */
$fileContents = Storage::disk('report_templates')->get(
"{$company->id}/test-template.json"
);
Expand All @@ -107,7 +107,7 @@ public function it_updates_template_blocks(): void
#[Group('crud')]
public function it_snaps_blocks_to_grid_on_update(): void
{
/* Arrange */
/* arrange */
$company = Company::factory()->create();
$user = User::factory()->create();
$user->companies()->attach($company);
Expand All @@ -134,10 +134,10 @@ public function it_snaps_blocks_to_grid_on_update(): void
],
];

/* Act */
/* act */
$this->service->updateTemplate($template, $blocksWithValidPosition);

/* Assert */
/* assert */
$fileContents = Storage::disk('report_templates')->get(
"{$company->id}/test-template.json"
);
Expand All @@ -153,7 +153,7 @@ public function it_snaps_blocks_to_grid_on_update(): void
#[Group('crud')]
public function it_persists_updates_to_filesystem(): void
{
/* Arrange */
/* arrange */
$company = Company::factory()->create();
$user = User::factory()->create();
$user->companies()->attach($company);
Expand Down Expand Up @@ -205,10 +205,10 @@ public function it_persists_updates_to_filesystem(): void
],
];

/* Act */
/* act */
$this->service->updateTemplate($template, $updatedBlocks);

/* Assert */
/* assert */
Storage::disk('report_templates')->assertExists(
"{$company->id}/test-template.json"
);
Expand Down
Loading