PHP Classes

File: tests/Component/AbstractComponent.php

Recommend this page to a friend!
  Classes of WsdlToPhp   PHP Code Generator   tests/Component/AbstractComponent.php   Download  
File: tests/Component/AbstractComponent.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: PHP Code Generator
Generate PHP code elements programatically
Author: By
Last change: issue #11 - implement type hinted class property,
refactor type hinted elements,
refactor assigned value elements,
refactor access restricted elements,
refactor AbstractComponent and inherited classes
format source code using PHP CS fixer @PhpCsFixer rule
Date: 3 years ago
Size: 1,085 bytes
 

Contents

Class file image Download
<?php

declare(strict_types=1);

namespace
WsdlToPhp\PhpGenerator\Tests\Component;

use
InvalidArgumentException;
use
WsdlToPhp\PhpGenerator\Component\AbstractComponent as AbstractComponentComponent;
use
WsdlToPhp\PhpGenerator\Tests\TestCase;

/**
 * @internal
 * @coversDefaultClass
 */
class AbstractComponent extends TestCase
{
    public function
assertSameContent($function, AbstractComponentComponent $component)
    {
       
$class = get_called_class();
       
$filename = sprintf(__DIR__.'/../resources/%s_%s.php', implode('', array_slice(explode('\\', $class), -1, 1)), substr($function, 4));
        if (!
is_file($filename)) {
            throw new
InvalidArgumentException(sprintf('Unable to locate "%s" content file for function "%s::%s"', $filename, $class, $function));
        }

       
// uncomment to write valid content into tested file
        // file_put_contents($filename, $component->toString());

       
$this->assertSame(file_get_contents($filename), $component->toString());
       
$this->assertSame($component->toString(), (string) $component);
    }
}