[ Index ] |
|
Code source de eZ Publish 3.9.0 |
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 eztesttemplateoutput.php 30 */ 31 32 /*! 33 \class eZTestTemplateOutput eztesttemplateoutput.php 34 \brief The class eZTestTemplateOutput does 35 36 */ 37 38 class eZTestProcessedTemplateOperator extends eZTestCase 39 { 40 /*! 41 Constructor 42 */ 43 function eZTestProcessedTemplateOperator( $name = false ) 44 { 45 $this->eZTestCase( $name ); 46 47 foreach ( glob('tests/eztemplate/operators/*.tpl') as $template ) 48 { 49 $this->addTemplateTest( $template ); 50 } 51 } 52 53 function addTemplateTest( $file ) 54 { 55 $name = str_replace( 'tests/eztemplate/operators/', '', $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 $tpl->reset(); 76 77 $tpl->setIsDebugEnabled( false ); 78 eZTemplateCompiler::setSettings( array( 'compile' => false, 79 'comments' => false, 80 'accumulators' => false, 81 'timingpoints' => false, 82 'fallbackresource' => false, 83 'nodeplacement' => false, 84 'execution' => true, 85 'generate' => true, 86 'compilation-directory' => 'tests/eztemplate/compilation' ) ); 87 88 preg_match( "/^(.+).tpl/", $templateFile, $matches ); 89 $phpFile = $matches[1] . '.php'; 90 91 if ( file_exists( $phpFile ) ) 92 { 93 include( $phpFile ); 94 } 95 96 $actual = $tpl->fetch( $templateFile ); 97 98 $tr->assert( !$tpl->hasErrors(), 'Template errors, details will be in debug output' ); 99 $tr->assert( !$tpl->hasWarnings(), 'Template warnings, details will be in debug output' ); 100 101 $actualFileName = str_replace( '.tpl', '.pout', $templateFile ); 102 $fp = fopen( $actualFileName, 'w' ); 103 fwrite( $fp, $actual ); 104 fclose( $fp ); 105 106 $tr->assert( strcmp( $actual, $expected ) == 0, 'String compare of processed results' ); 107 } 108 } 109 110 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |