[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/tests/eztemplate/ -> eztestprocessedtemplatefunction.php (source)

   1  <?php
   2  //
   3  // Definition of eZTestTemplateOutput class
   4  //
   5  // Created on: <30-Jan-2004 11:59:49 >
   6  //
   7  // SOFTWARE NAME: eZ publish
   8  // SOFTWARE RELEASE: 3.9.0
   9  // BUILD VERSION: 17785
  10  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
  11  // SOFTWARE LICENSE: GNU General Public License v2.0
  12  // NOTICE: >
  13  //   This program is free software; you can redistribute it and/or
  14  //   modify it under the terms of version 2.0  of the GNU General
  15  //   Public License as published by the Free Software Foundation.
  16  //
  17  //   This program is distributed in the hope that it will be useful,
  18  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  19  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20  //   GNU General Public License for more details.
  21  //
  22  //   You should have received a copy of version 2.0 of the GNU General
  23  //   Public License along with this program; if not, write to the Free
  24  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  25  //   MA 02110-1301, USA.
  26  //
  27  //
  28  
  29  /*! \file eztesttemplatefunction.php
  30  */
  31  
  32  /*!
  33    \class eZTestTemplateFunction eztesttemplatefunction.php
  34    \brief The class eZTestTemplateFunction does
  35  
  36  */
  37  
  38  class eZTestProcessedTemplateFunction extends eZTestCase
  39  {
  40      /*!
  41       Constructor
  42      */
  43      function eZTestProcessedTemplateFunction( $name = false )
  44      {
  45          $this->eZTestCase( $name );
  46  
  47          foreach ( glob('tests/eztemplate/functions/*.tpl') as $template )
  48          {
  49              $this->addTemplateTest( $template );
  50          }
  51      }
  52  
  53      function addTemplateTest( $file )
  54      {
  55          $name = str_replace( 'tests/eztemplate/functions/', '', $file );
  56          $name = str_replace( '.tpl', '', $name );
  57          $name = ucwords( $name );
  58          $this->addTest( 'testTemplate', $name, $file );
  59      }
  60  
  61      function testTemplate( &$tr, $templateFile )
  62      {
  63          $expectedFileName = str_replace( '.tpl', '.exp', $templateFile );
  64          if ( file_exists( $expectedFileName ) )
  65          {
  66              $expected = file_get_contents( $expectedFileName );
  67          }
  68          else
  69          {
  70              $tr->assert( false, 'Missing expected test file ' . $expectedFileName );
  71          }
  72  
  73          include_once( 'kernel/common/template.php' );
  74          $tpl =& templateInit();
  75          eZTemplateDesignResource::setDesignStartPath( "tests/eztemplate/design" );
  76          $tpl->reset();
  77  
  78          $tpl->setIsDebugEnabled( false );
  79          $tpl->setIsCachingAllowed( false );
  80  
  81          eZTemplateCompiler::setSettings( array( 'compile' => false,
  82                                                  'comments' => false,
  83                                                  'accumulators' => false,
  84                                                  'timingpoints' => false,
  85                                                  'fallbackresource' => false,
  86                                                  'nodeplacement' => false,
  87                                                  'execution' => true,
  88                                                  'generate' => true,
  89                                                  'compilation-directory' => 'tests/eztemplate/compilation' ) );
  90  
  91          preg_match( "/^(.+).tpl/", $templateFile, $matches );
  92          $phpFile = $matches[1] . '.php';
  93  
  94          if ( file_exists( $phpFile ) )
  95          {
  96              include( $phpFile );
  97          }
  98  
  99          $actual = $tpl->fetch( $templateFile );
 100  
 101          $tr->assert( !$tpl->hasErrors(), 'Template errors, details will be in debug output' );
 102          $tr->assert( !$tpl->hasWarnings(), 'Template warnings, details will be in debug output' );
 103  
 104          $actualFileName = str_replace( '.tpl', '.pout', $templateFile );
 105          $fp = fopen( $actualFileName, 'w' );
 106          fwrite( $fp, $actual );
 107          fclose( $fp );
 108  
 109          $tr->assert( strcmp( $actual, $expected ) == 0, 'String compare of results' );
 110      }
 111  }
 112  
 113  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7