PHP Classes

File: test/ssa/runner/converter/FileEncoderTest.php

Recommend this page to a friend!
  Packages of thomas   SSA   test/ssa/runner/converter/FileEncoderTest.php   Download  
File: test/ssa/runner/converter/FileEncoderTest.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: SSA
Call PHP classes from JavaScript on Web pages
Author: By
Last change:
Date: 12 years ago
Size: 1,062 bytes
 

 

Contents

Class file image Download
<?php

namespace ssa\runner\converter;

use ssa\runner\converter\FileEncoder;

/**
 * Description of FileEncoderTest
 *
 * @author thomas
 */
class FileEncoderTest extends \PHPUnit_Framework_TestCase {
    
    private $encoder;
    
    public function setUp() {
        $this->encoder = new FileEncoder();
    }
    
    /**
     * test encoder for a file on an array  
     */
    public function testArrayFileEncoder() {
        $result = $this->encoder->encode(array(
            'type' => 'text/php',
            'tmp_name' => __FILE__
        ));
        $this->assertEquals(file_get_contents(__FILE__), $result);
        $this->assertEquals(array(
            'Content-type' => 'text/php'
        ), $this->encoder->getHeaders());
    }
    
    public function testFileEncoderWithString() {
        $result = $this->encoder->encode(__FILE__);
        $this->assertEquals(file_get_contents(__FILE__), $result);
        $this->assertEquals(array(
            'Content-type' => mime_content_type(__FILE__)
        ), $this->encoder->getHeaders());
    }
}