HEX
Server: Apache
System: Linux webd004.cluster130.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User: frenchy (106757)
PHP: 7.4.33
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/frenchy/www/french-american.org/current/vendor/timber/timber/tests/test-timber-shortcodes.php
<?php

	class TestTimberShortcodes extends Timber_UnitTestCase {

		function testShortcodes(){
			add_shortcode('timber_shortcode', function($text){
				return 'timber '.$text[0];
			});
			$return = Timber::compile('assets/test-shortcodes.twig');
			$this->assertEquals('hello timber foo', trim($return));
		}

		/**
		 * @ticket #2268
		 */
		function testCustomFieldShortcode() {
			add_shortcode( 'foobar', function( $atts ) {
				return 'barfoo';
			} );

			$post_id = $this->factory->post->create();
			update_post_meta( $post_id, 'customfield', '[foobar]' );
			$template = '{{ post.customfield | shortcodes }}';

			$post = Timber::get_post($post_id);
			$compiled = Timber::compile_string($template, ['post' => $post]);

			$this->assertEquals('barfoo', $compiled);
		}
	}