PHP Classes

File: tests/File/StructEnumTest.php

Recommend this page to a friend!
  Classes of WsdlToPhp   PHP SOAP Package Generator   tests/File/StructEnumTest.php   Download  
File: tests/File/StructEnumTest.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:
Date: 9 years ago
Size: 5,697 bytes
 

Contents

Class file image Download
<?php

namespace WsdlToPhp\PackageGenerator\Tests\File;

use
WsdlToPhp\PackageGenerator\File\StructEnum as EnumFile;
use
WsdlToPhp\PackageGenerator\Model\Struct as StructModel;

class
StructEnumTest extends AbstractFile
{
   
/**
     * @expectedException \InvalidArgumentException
     */
   
public function testSetModelGoodNameTooManyAttributesWithException()
    {
       
$instance = self::bingGeneratorInstance();
       
$enum = new EnumFile($instance, 'Foo');
       
$enum->setModel(new StructModel($instance, 'FooEnum'));
    }
   
/**
     *
     */
   
public function testWriteBingSearchEnumAdultOption()
    {
       
$generator = self::bingGeneratorInstance();
        if ((
$model = $generator->getStruct('AdultOption')) instanceof StructModel) {
           
$struct = new EnumFile($generator, $model->getName());
           
$struct
               
->setModel($model)
                ->
write();
           
$this->assertSameFileContent('ValidApiAdultOption', $struct);
        } else {
           
$this->assertFalse(true, 'Unable to find AdultOption enumeration for file generation');
        }
    }
   
/**
     *
     */
   
public function testWriteBingSearchEnumSourceType()
    {
       
$generator = self::bingGeneratorInstance();
        if ((
$model = $generator->getStruct('SourceType')) instanceof StructModel) {
           
$struct = new EnumFile($generator, $model->getName());
           
$struct
               
->setModel($model)
                ->
write();
           
$this->assertSameFileContent('ValidApiSourceType', $struct);
        } else {
           
$this->assertFalse(true, 'Unable to find SourceType enumeration for file generation');
        }
    }
   
/**
     *
     */
   
public function testWriteReformaHouseStageEnum()
    {
       
$generator = self::reformaGeneratorInstance();
        if ((
$model = $generator->getStruct('HouseStageEnum')) instanceof StructModel) {
           
$struct = new EnumFile($generator, $model->getName());
           
$struct
               
->setModel($model)
                ->
write();
           
$this->assertSameFileContent('ValidApiHouseStageEnum', $struct);
        } else {
           
$this->assertFalse(true, 'Unable to find HouseStageEnum enumeration for file generation');
        }
    }
   
/**
     *
     */
   
public function testWriteOmnitureDsWeblogFormats()
    {
       
$generator = self::omnitureGeneratorInstance();
        if ((
$model = $generator->getStruct('ds_weblog_formats')) instanceof StructModel) {
           
$struct = new EnumFile($generator, $model->getName());
           
$struct
               
->setModel($model)
                ->
write();
           
$this->assertSameFileContent('ValidApiDs_weblog_formats', $struct);
        } else {
           
$this->assertFalse(true, 'Unable to find ds_weblog_formats enumeration for file generation');
        }
    }
   
/**
     *
     */
   
public function testWriteBingSearchEnumWebSearchOption()
    {
       
$generator = self::bingGeneratorInstance(true);
        if ((
$model = $generator->getStruct('WebSearchOption')) instanceof StructModel) {
           
$generator->setOptionGenericConstantsNames(true);
           
$struct = new EnumFile($generator, $model->getName());
           
$struct
               
->setModel($model)
                ->
write();
           
$this->assertSameFileContent('ValidApiWebSearchOption', $struct);
        } else {
           
$this->assertFalse(true, 'Unable to find WebSearchOption enumeration for file generation');
        }
    }
   
/**
     *
     */
   
public function testWriteBingSearchEnumPhonebookSortOption()
    {
       
$generator = self::bingGeneratorInstance(true);
        if ((
$model = $generator->getStruct('PhonebookSortOption')) instanceof StructModel) {
           
$generator
               
->setOptionNamespacePrefix('Std\Opt');
           
$struct = new EnumFile($generator, $model->getName());
           
$struct
               
->setModel($model)
                ->
write();
           
$this->assertSameFileContent('ValidApiPhonebookSortOption', $struct);
        } else {
           
$this->assertFalse(true, 'Unable to find PhonebookSortOption enumeration for file generation');
        }
    }
   
/**
     *
     */
   
public function testWriteBingSearchEnumPhonebookSortOptionSuffixed()
    {
       
$generator = self::bingGeneratorInstance(true);
        if ((
$model = $generator->getStruct('PhonebookSortOption')) instanceof StructModel) {
           
$generator
               
->setOptionPrefix('')
                ->
setOptionSuffix('Api');
           
$struct = new EnumFile($generator, $model->getName());
           
$struct
               
->setModel($model)
                ->
write();
           
$this->assertSameFileContent('ValidApiPhonebookSortOptionApi', $struct);
        } else {
           
$this->assertFalse(true, 'Unable to find PhonebookSortOption enumeration for file generation');
        }
    }
   
/**
     *
     */
   
public function testDestination()
    {
       
$generator = self::bingGeneratorInstance(true);
        if ((
$model = $generator->getStruct('PhonebookSortOption')) instanceof StructModel) {
           
$generator
               
->setOptionPrefix('')
                ->
setOptionSuffix('Api');
           
$struct = new EnumFile($generator, $model->getName());
           
$struct->setModel($model);

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