PHP Classes
elePHPant
Icontem

File: tests/org/majkel/tcpdfwarper/AbstractTestCase.php

Recommend this page to a friend!
  Classes of Michal Kowalik  >  TCPDF Warper  >  tests/org/majkel/tcpdfwarper/AbstractTestCase.php  >  Download  
File: tests/org/majkel/tcpdfwarper/AbstractTestCase.php
Role: Unit test script
Content type: text/plain
Description: tests
Class: TCPDF Warper
Create PDF documents using TCPDF fluent interface
Author: By
Last change: composer update fix
Sensio: Commented code should not be committed
Date: 3 years ago
Size: 1,589 bytes
 

Contents

Class file image Download
<?php
/**
 * Created by PhpStorm.
 * Package: org\majkel\tcpdfwarper
 * User: Micha? (majkel) Kowalik <maf.michal@gmail.com>
 * Date: 12/28/2014
 * Time: 18:17
 */

namespace org\majkel\tcpdfwarper;

use
Xpmock\TestCaseTrait;

/**
 * Class AbstractTestCase
 * @package org\majkel\tcpdfwarper
 * @coversDefaultClass \org\majkel\tcpdfwarper\AbstractOp
 */
class AbstractTestCase extends \PHPUnit_Framework_TestCase {

    use
TestCaseTrait;

   
/**
     * @var string
     */
   
protected $tcpdfClassName;

    const
DEFAULT_TCPDF = '\TCPDF';

    const
ENV_PACKAGE = 'TCPDF_PACKAGE';

    protected static
$packageMapping = array(
           
'tecnickcom/tcpdf' => self::DEFAULT_TCPDF,
           
'onigoetz/fpdi_tcpdf' => '\fpdi\FPDI',
           
'dummy' => '\org\majkel\tcpdfwarper\DummyTcpdf',
    );

   
/**
     * @return string
     * @throws \Exception
     */
   
public function getTcpdfClass() {
        if (
is_null($this->tcpdfClassName)) {
           
$package = strtolower(trim(getenv(self::ENV_PACKAGE)));
            if (
$package) {
                if (isset(
self::$packageMapping[$package])) {
                   
$this->tcpdfClassName = self::$packageMapping[$package];
                }
                else {
                    throw new \
Exception("Unknown TCPDF package `$package`");
                }
            }
            else {
               
$this->tcpdfClassName = self::DEFAULT_TCPDF;
            }
        }
        return
$this->tcpdfClassName;
    }

   
/**
     * @return \PHPUnit_Framework_MockObject_MockObject
     */
   
public function getTcpdfMock() {
        return
$this->getMockBuilder($this->getTcpdfClass())
                ->
disableOriginalConstructor()
                ->
getMock();
    }

   
/**
     * For strict mode marks test as success
     */
   
protected function success() {
       
self::assertTrue(true);
    }
}