File: D:/HostingSpaces/SBogers10/shop.komma.nl/tests/Unit/DocumentTest.php
<?php
use Komma\KMS\Documents\Models\Document;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
class DocumentTest extends TestCase
{
use DatabaseTransactions;
/**
* Setup the test environment.
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
}
/**
* @group DocumentTest
* @test
*/
public function testDocumentPathUrl()
{
//Fake a document that was uploaded on a windows platform (\ Path directory seperators)
$windowsDocument = new Document();
$windowsDocument->key = 'Documents-page';
$windowsDocument->name = 'Schermafbeelding 2019-04-24 om 12.10.01';
$windowsDocument->file_system_path = '\uploads\pages\schermafbeelding-2019-04-24-om-121001-029260100-1557224346.png';
$windowsDocument->mime_type = 'image/png';
$windowsDocument->sort_order = '1';
$windowsDocument->documentable_id = '3';
$windowsDocument->documentable_type = 'App\Pages\Models\Page';
$windowsDocument->thumb_image_url = '/uploads/pages/schermafbeelding-2019-04-24-om-121001-029260100-1557224346_thumb.png';
$windowsDocument->small_image_url = '/uploads/pages/schermafbeelding-2019-04-24-om-121001-029260100-1557224346_small.png';
$windowsDocument->medium_image_url = '/uploads/pages/schermafbeelding-2019-04-24-om-121001-029260100-1557224346_medium.png';
$windowsDocument->large_image_url = '/uploads/pages/schermafbeelding-2019-04-24-om-121001-029260100-1557224346_large.png';
$windowsDocument->created_at = '2019-05-07 12:19:06';
$windowsDocument->updated_at = '2019-05-07 12:19:21';
$unixDocument = new Document();
$unixDocument->key = 'Documents-page';
$unixDocument->name = 'Schermafbeelding 2019-04-24 om 12.10.01';
$unixDocument->file_system_path = '/uploads/pages/schermafbeelding-2019-04-24-om-121001-029260100-1557224346.png';
$unixDocument->mime_type = 'image/png';
$unixDocument->sort_order = '1';
$unixDocument->documentable_id = '3';
$unixDocument->documentable_type = 'App\Pages\Models\Page';
$unixDocument->thumb_image_url = '/uploads/pages/schermafbeelding-2019-04-24-om-121001-029260100-1557224346_thumb.png';
$unixDocument->small_image_url = '/uploads/pages/schermafbeelding-2019-04-24-om-121001-029260100-1557224346_small.png';
$unixDocument->medium_image_url = '/uploads/pages/schermafbeelding-2019-04-24-om-121001-029260100-1557224346_medium.png';
$unixDocument->large_image_url = '/uploads/pages/schermafbeelding-2019-04-24-om-121001-029260100-1557224346_large.png';
$unixDocument->created_at = '2019-05-07 12:19:06';
$unixDocument->updated_at = '2019-05-07 12:19:21';
//Assert that the unix document path stays the same when using the
$this->assertEquals($unixDocument->file_system_path, $unixDocument->file_url);
$this->assertNotEquals($windowsDocument->file_system_path, $windowsDocument->file_url);
$this->assertEquals('/uploads/pages/schermafbeelding-2019-04-24-om-121001-029260100-1557224346.png', $windowsDocument->file_url);
}
}