Skip to content
Snippets Groups Projects
TestCase.php 967 B
Newer Older
<?php

namespace Syna\Test;

use Mockery\Adapter\Phpunit\MockeryTestCase;

class TestCase extends MockeryTestCase
{
    protected $templatePath;

    protected function setUp()
    {
        $this->templatePath = '/tmp/syna-test';
        if (file_exists($this->templatePath)) {
            system('rm -Rf ' . $this->templatePath);
        }
        mkdir($this->templatePath);
    }

    protected function createTemplate(string $path, string $content): string
    {
        $path = $this->templatePath . DIRECTORY_SEPARATOR . $path;
        if (!file_exists(dirname($path))) {
            mkdir(dirname($path), 0755, true);
        }
        file_put_contents($path, $content);
        return $path;
    }
Thomas Flori's avatar
Thomas Flori committed
    protected static function accessProtected($obj, $prop)
    {
        $reflection = new \ReflectionClass($obj);
        $property = $reflection->getProperty($prop);
        $property->setAccessible(true);
        return $property->getValue($obj);
    }