for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Btccom\JustEncrypt\Test;
abstract class AbstractTestCase extends \PHPUnit_Framework_TestCase
{
/**
* @var array
*/
private $vectors = null;
* AbstractTestCase constructor.
* @param null $name
* @param array $data
* @param string $dataName
public function __construct($name = null, array $data = [], $dataName = '')
$this->getTestVectors();
parent::__construct($name, $data, $dataName);
}
* @param string $file
* @return string
public function dataPath($file)
return __DIR__ . '/data/' . $file;
* @param string $filename
public function dataFile($filename)
$contents = file_get_contents($this->dataPath($filename));
if (false === $contents) {
throw new \RuntimeException('Failed to data file ' . $filename);
return $contents;
* @return array
private function readTestVectorsFile()
$decoded = json_decode(file_get_contents(__DIR__ .'/data/crypt_vectors.json'), true);
if (!$decoded || json_last_error() !== JSON_ERROR_NONE) {
throw new \RuntimeException('failed to read vectors file');
return $decoded;
public function getTestVectors()
if (null === $this->vectors) {
$this->vectors = $this->readTestVectorsFile();
return $this->vectors;