40 lines
778 B
PHP
40 lines
778 B
PHP
<?php
|
|
/**
|
|
* Logo sanitizer tests.
|
|
*
|
|
* @package LogoSoup\Tests
|
|
*/
|
|
|
|
use LogoSoup\Support\Logo_Sanitizer;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* Tests collection sanitization.
|
|
*/
|
|
class LogoSanitizerTest extends TestCase {
|
|
/**
|
|
* Test invalid rows are removed.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function test_sanitize_collection_skips_invalid_entries() {
|
|
$sanitized = Logo_Sanitizer::sanitize_collection(
|
|
array(
|
|
array(
|
|
'id' => '4',
|
|
'url' => 'https://example.com/logo.svg',
|
|
'alt' => '<b>Alpha</b>',
|
|
'link' => 'https://example.com',
|
|
),
|
|
array(
|
|
'alt' => 'Missing URL',
|
|
),
|
|
)
|
|
);
|
|
|
|
$this->assertCount( 1, $sanitized );
|
|
$this->assertSame( 'Alpha', $sanitized[0]['alt'] );
|
|
$this->assertSame( 4, $sanitized[0]['id'] );
|
|
}
|
|
}
|