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: test __toString method
Implement declare statement,
Code requires PHP 7.4,
Code cleaning and various tests
Date: 26 days ago
Size: 1,049 bytes
 

Contents

Class file image Download
<?php

declare(strict_types=1);

namespace
WsdlToPhp\PhpGenerator\Tests\Component;

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

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(file_get_contents($filename), (string) $component);
    }
}


For more information send a message to info at phpclasses dot org.