/tests/tests/lib/ezfile/ezfiledownload_test.php
PHP | 77 lines | 59 code | 10 blank | 8 comment | 0 complexity | 13d99965a8f326498a7132fe686308ee MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
- <?php
- /**
- * File containing the eZFileDownloadTest class
- *
- * @copyright Copyright (C) eZ Systems AS. All rights reserved.
- * @license For full copyright and license information view LICENSE file distributed with this source code.
- * @version //autogentag//
- * @package tests
- */
- class eZFileDownloadTest extends ezpTestCase
- {
- public function setUp()
- {
- parent::setUp();
- $this->file = dirname( __FILE__ ) . "/data/file.txt";
- $this->content = file_get_contents( $this->file );
- }
- public function testDownload()
- {
- ob_start();
- $this->assertTrue( eZFile::downloadContent( $this->file ) );
- $this->assertEquals( $this->content , ob_get_clean() );
- }
- public function testDownloadOffset()
- {
- ob_start();
- $this->assertTrue( eZFile::downloadContent( $this->file, 8000 ) );
- $this->assertEquals( substr( $this->content, -192 ) , ob_get_clean() );
- }
- public function testDownloadSize()
- {
- ob_start();
- $this->assertTrue( eZFile::downloadContent( $this->file, 0, 100 ) );
- $this->assertEquals( substr( $this->content, 0, 100 ) , ob_get_clean() );
- }
- public function testDownloadOffsetSize()
- {
- ob_start();
- $this->assertTrue( eZFile::downloadContent( $this->file, 8000, 100 ) );
- $this->assertEquals( substr( $this->content, 8000, 100 ) , ob_get_clean() );
- }
- public function testDownloadOffsetSizeTooHigh()
- {
- ob_start();
- $this->assertTrue( eZFile::downloadContent( $this->file, 8000, 192 ) );
- $this->assertEquals( substr( $this->content, 8000 ) , ob_get_clean() );
- }
- public function testDownloadOffsetSizeWayTooHigh()
- {
- ob_start();
- $this->assertTrue( eZFile::downloadContent( $this->file, 8000, 1e5 ) );
- $this->assertEquals( substr( $this->content, 8000 ) , ob_get_clean() );
- }
- public function testDownloadOffsetTooBig()
- {
- ob_start();
- $this->assertTrue( eZFile::downloadContent( $this->file, 8193 ) );
- $this->assertEquals( "" , ob_get_clean() );
- }
- public function testDownloadNoFile()
- {
- ob_start();
- $this->assertFalse( eZFile::downloadContent( "unexisting.txt" ) );
- $this->assertEquals( "" , ob_get_clean() );
- }
- }
- ?>