PHP Classes

File: test/Picamator/SteganographyKit/BaseTest.php

Recommend this page to a friend!
  Classes of Sergii Pryz   PHP Steganography Kit   test/Picamator/SteganographyKit/BaseTest.php   Download  
File: test/Picamator/SteganographyKit/BaseTest.php
Role: Unit test script
Content type: text/plain
Description: Class source
Class: PHP Steganography Kit
Library of algorithms to encode messages in images
Author: By
Last change:
Date: 10 years ago
Size: 1,352 bytes
 

Contents

Class file image Download
<?php
/**
 * Base SteganographyKit UnitTest
 *
 * @link https://github.com/picamator/SteganographyKit
 * @license http://opensource.org/licenses/BSD-3-Clause New BSD License
 */

abstract class BaseTest extends PHPUnit_Framework_TestCase
{
   
/**
     * Path to the data folder
     *
     * @var string
     */
   
protected $dataPath = './test/Picamator/SteganographyKit/data/';
      
   
/**
     * Path to steganography folder
     *
     * @var string
     */
   
static protected $stegoPath = 'stego';
   
   
/**
     * Gets full path to data
     *
     * @param string $path
     * @retutn string|boolean - full path or false if failed
     */
   
protected function getDataPath($path)
    {
       
$fullPath = $this->dataPath . $path;
       
$dirPath = (is_file($fullPath)) ? dirname($fullPath) : $fullPath;
      
        if (!
file_exists($dirPath)) {
           
mkdir($dirPath, 0777, true);
        }

        return
realpath($fullPath);
    }
   
   
/**
     * Clear stego path
     */
   
protected function clearStegoPath()
    {
       
$path = $this->getDataPath(self::$stegoPath);
        foreach (new \
DirectoryIterator($path) as $fileInfo) {
            if(
$fileInfo->isDot()) {
                continue;
            }
           
           
unlink($fileInfo->getPathname());
        }
    }
}