PHP Classes

File: tests/File/StructTest.php

Recommend this page to a friend!
  Classes of WsdlToPhp   PHP SOAP Package Generator   tests/File/StructTest.php   Download  
File: tests/File/StructTest.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: PHP SOAP Package Generator
Generate package to call SOAP services using WSDL
Author: By
Last change: issue #41 - add unit tests methods
Date: 8 years ago
Size: 7,209 bytes
 

Contents

Class file image Download
<?php

namespace WsdlToPhp\PackageGenerator\Tests\File;

use
WsdlToPhp\PackageGenerator\Model\EmptyModel;
use
WsdlToPhp\PackageGenerator\Model\Struct as StructModel;
use
WsdlToPhp\PackageGenerator\File\Struct as StructFile;

class
StructTest extends AbstractFile
{
   
/**
     * @expectedException \InvalidArgumentException
     */
   
public function testSetModelGoodNameTooManyAttributesWithException()
    {
       
$instance = self::bingGeneratorInstance();
       
$struct = new StructFile($instance, 'Foo');
       
$struct->setModel(new EmptyModel($instance, 'Foo'));
    }
   
/**
     * @expectedException \InvalidArgumentException
     */
   
public function testExceptionOnWrite()
    {
       
$file = new StructFile(self::bingGeneratorInstance(), 'foo');

       
$file->write();
    }
   
/**
     *
     */
   
public function testGetFileName()
    {
       
$model = new StructModel(self::bingGeneratorInstance(), 'Foo');
       
$file = new StructFile(self::bingGeneratorInstance(), 'foo');
       
$file->setModel($model);

       
$this->assertSame(sprintf('%s%s%s/%s.php', self::getTestDirectory(), StructFile::SRC_FOLDER, $model->getContextualPart(), $model->getPackagedName(false)), $file->getFileName());
    }
   
/**
     *
     */
   
public function testWriteBingSearchStructQuery()
    {
       
$generator = self::bingGeneratorInstance();
        if ((
$model = $generator->getStruct('Query')) instanceof StructModel) {
           
$struct = new StructFile($generator, $model->getName());
           
$struct
               
->setModel($model)
                ->
write();
           
$this->assertSameFileContent('ValidApiQuery', $struct);
        } else {
           
$this->assertFalse(true, 'Unable to find Query struct for file generation');
        }
    }
   
/**
     *
     */
   
public function testWriteBingSearchStructVideoRequest()
    {
       
$generator = self::bingGeneratorInstance();
        if ((
$model = $generator->getStruct('VideoRequest')) instanceof StructModel) {
           
$struct = new StructFile($generator, $model->getName());
           
$struct
               
->setModel($model)
                ->
write();
           
$this->assertSameFileContent('ValidApiVideoRequest', $struct);
        } else {
           
$this->assertFalse(true, 'Unable to find VideoRequest struct for file generation');
        }
    }
   
/**
     *
     */
   
public function testWriteBingSearchStructSearchRequest()
    {
       
$generator = self::bingGeneratorInstance();
        if ((
$model = $generator->getStruct('SearchRequest')) instanceof StructModel) {
           
$struct = new StructFile($generator, $model->getName());
           
$struct
               
->setModel($model)
                ->
write();
           
$this->assertSameFileContent('ValidApiSearchRequest', $struct);
        } else {
           
$this->assertFalse(true, 'Unable to find SearchRequest struct for file generation');
        }
    }
   
/**
     *
     */
   
public function testWriteActonStructItem()
    {
       
$generator = self::actonGeneratorInstance();
        if ((
$model = $generator->getStruct('Item')) instanceof StructModel) {
           
$struct = new StructFile($generator, $model->getName());
           
$struct
               
->setModel($model)
                ->
write();
           
$this->assertSameFileContent('ValidApiItem', $struct);
        } else {
           
$this->assertFalse(true, 'Unable to find Item struct for file generation');
        }
    }
   
/**
     *
     */
   
public function testWriteOdigeoStructFareItinerary()
    {
       
$generator = self::odigeoGeneratorInstance();
        if ((
$model = $generator->getStruct('fareItinerary')) instanceof StructModel) {
           
$struct = new StructFile($generator, $model->getName());
           
$struct
               
->setModel($model)
                ->
write();
           
$this->assertSameFileContent('ValidApiFareItinerary', $struct);
        } else {
           
$this->assertFalse(true, 'Unable to find fareItinerary struct for file generation');
        }
    }
   
/**
     *
     */
   
public function testWriteBingStructNewsArticle()
    {
       
$generator = self::bingGeneratorInstance();
        if ((
$model = $generator->getStruct('NewsArticle')) instanceof StructModel) {
           
$generator->setOptionStructClass('\Std\Opt\StructClass');
           
$struct = new StructFile($generator, $model->getName());
           
$struct
               
->setModel($model)
                ->
write();
           
$this->assertSameFileContent('ValidApiNewsArticle', $struct);
        } else {
           
$this->assertFalse(true, 'Unable to find NewsArticle struct for file generation');
        }
    }
   
/**
     *
     */
   
public function testWriteWcfStructOffer()
    {
       
$generator = self::wcfGeneratorInstance();
        if ((
$model = $generator->getStruct('offer')) instanceof StructModel) {
           
$struct = new StructFile($generator, $model->getName());
           
$struct
               
->setModel($model)
                ->
write();
           
$this->assertSameFileContent('ValidApiOffer', $struct);
        } else {
           
$this->assertFalse(true, 'Unable to find offer struct for file generation');
        }
    }
   
/**
     *
     */
   
public function testWriteYandexDirectApiStructAddRequest()
    {
       
$generator = self::yandexDirectApiAdGroupsGeneratorInstance();
        if ((
$model = $generator->getStruct('AddRequest')) instanceof StructModel) {
           
$struct = new StructFile($generator, $model->getName());
           
$struct
               
->setModel($model)
                ->
write();
           
$this->assertSameFileContent('ValidAddRequest', $struct);
        } else {
           
$this->assertFalse(true, 'Unable to find AddRequest struct for file generation');
        }
    }
   
/**
     *
     */
   
public function testWriteYandexDirectApiStructAdGroupsSelectionCriteria()
    {
       
$generator = self::yandexDirectApiAdGroupsGeneratorInstance();
        if ((
$model = $generator->getStruct('AdGroupsSelectionCriteria')) instanceof StructModel) {
           
$struct = new StructFile($generator, $model->getName());
           
$struct
               
->setModel($model)
                ->
write();
           
$this->assertSameFileContent('ValidAdGroupsSelectionCriteria', $struct);
        } else {
           
$this->assertFalse(true, 'Unable to find AdGroupsSelectionCriteria struct for file generation');
        }
    }
   
/**
     *
     */
   
public function testDestination()
    {
       
$generator = self::bingGeneratorInstance();
        if ((
$model = $generator->getStruct('NewsArticle')) instanceof StructModel) {
           
$generator->setOptionStructClass('\Std\Opt\StructClass');
           
$struct = new StructFile($generator, $model->getName());
           
$struct->setModel($model);

           
$this->assertSame(sprintf('%s%s%s/', self::getTestDirectory(), StructFile::SRC_FOLDER, $model->getContextualPart()), $struct->getFileDestination());
        } else {
           
$this->assertFalse(true, 'Unable to find NewsArticle struct for file generation');
        }
    }
}