fix: keep internal agribusiness delivery notes out of portal presentation
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\Opportunity;
|
||||
use App\Services\CorridorAgribusinessOpportunities;
|
||||
use App\Services\OpportunityPublicText;
|
||||
use Tests\TestCase;
|
||||
|
||||
class OpportunityPublicTextTest extends TestCase
|
||||
{
|
||||
public function test_public_serialization_omits_generated_internal_notes_without_changing_original_or_other_content(): void
|
||||
{
|
||||
$source = ['source' => 'investimentos nos corredores.docx', 'source_sha256' => CorridorAgribusinessOpportunities::SOURCE_HASH, 'corridor' => 'Corredor de Maputo'];
|
||||
$body = 'Produção de arroz.'."\n\nFonte: ".$source['source'].'; SHA-256 '.$source['source_sha256']."\n\n".CorridorAgribusinessOpportunities::LIMITATIONS;
|
||||
$record = new Opportunity(['description' => $body]);
|
||||
$record->workflow_context = ['corridor_agribusiness' => $source];
|
||||
$public = $record->toArray();
|
||||
$this->assertStringContainsString('Produção de arroz.', $public['description']);
|
||||
$this->assertStringNotContainsString('SHA-256', $public['description']);
|
||||
$this->assertStringNotContainsString('.docx', $public['description']);
|
||||
$this->assertSame($body, $record->description);
|
||||
$this->assertArrayNotHasKey('workflow_context', $public);
|
||||
$other = new Opportunity(['description' => $body]);
|
||||
$this->assertSame($body, OpportunityPublicText::description($other, $body));
|
||||
$this->assertSame('Texto revisto pela equipa.', OpportunityPublicText::description($record, 'Texto revisto pela equipa.'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user