2015-05-07 09:14:02 +02:00
|
|
|
<?php
|
2017-12-20 22:24:39 +01:00
|
|
|
|
2018-07-03 01:35:24 +02:00
|
|
|
namespace SilverStripe\TextExtraction\Tests;
|
|
|
|
|
|
|
|
use SilverStripe\Assets\File;
|
|
|
|
use SilverStripe\Core\Config\Config;
|
|
|
|
use SilverStripe\Dev\SapphireTest;
|
|
|
|
use SilverStripe\TextExtraction\Cache\FileTextCache\Database;
|
2017-12-20 22:24:39 +01:00
|
|
|
|
2015-11-18 05:07:31 +01:00
|
|
|
class FileTextCacheDatabaseTest extends SapphireTest
|
|
|
|
{
|
|
|
|
public function testTruncatesByMaxLength()
|
|
|
|
{
|
2018-07-03 01:35:24 +02:00
|
|
|
Config::modify()->set(Database::class, 'max_content_length', 5);
|
2017-12-20 22:24:39 +01:00
|
|
|
|
2018-07-03 01:35:24 +02:00
|
|
|
$cache = new Database();
|
|
|
|
$file = $this->getMockBuilder(File::class)->setMethods(['write'])->getMock();
|
2015-11-18 05:07:31 +01:00
|
|
|
$content = '0123456789';
|
|
|
|
$cache->save($file, $content);
|
2015-05-07 09:14:02 +02:00
|
|
|
|
2018-07-03 01:35:24 +02:00
|
|
|
$this->assertEquals($cache->load($file), '01234');
|
2015-11-18 05:07:31 +01:00
|
|
|
}
|
|
|
|
}
|