HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/delta/wp-content/themes/delta/vendor/timber/timber/tests/test-timber-post-content.php
<?php

	class TestTimberPostContent extends Timber_UnitTestCase {


	function testContent(){
		$quote = 'The way to do well is to do well.';
		$post_id = self::factory()->post->create();
		$post = new TimberPost($post_id);
		$post->post_content = $quote;
		wp_update_post($post);
		$this->assertEquals($quote, trim(strip_tags($post->content())));
		$this->assertEquals($quote, trim(strip_tags($post->get_content())));
	}

	function testContentPaged(){
		$quote = $page1 = 'The way to do well is to do well.';
		$quote .= '<!--nextpage-->';
		$quote .= $page2 = "And do not let your tongue get ahead of your mind.";

		$post_id = self::factory()->post->create();
		$post = new TimberPost($post_id);
		$post->post_content = $quote;
		wp_update_post($post);

		$this->assertEquals($page1, trim(strip_tags($post->content(1))));
		$this->assertEquals($page2, trim(strip_tags($post->content(2))));
		$this->assertEquals($page1, trim(strip_tags($post->get_content(0,1))));
		$this->assertEquals($page2, trim(strip_tags($post->get_content(0,2))));
	}

	function testPagedContent(){
		$quote = $page1 = 'Named must your fear be before banish it you can.';
		$quote .= '<!--nextpage-->';
		$quote .= $page2 = "No, try not. Do or do not. There is no try.";

		$post_id = self::factory()->post->create(array('post_content' => $quote));

		$this->go_to( get_permalink( $post_id ) );

		// @todo The below should work magically when the iterators are merged
		setup_postdata( get_post( $post_id ) );

		$post = Timber::get_post();
			$this->assertEquals($page1, trim(strip_tags( $post->paged_content() )));

		$pagination = $post->pagination();
		$this->go_to( $pagination['pages'][1]['link'] );

		setup_postdata( get_post( $post_id ) );
		$post = Timber::get_post();

		$this->assertEquals($page2, trim(strip_tags( $post->get_paged_content() )));
	}

	/**
	 * @ticket 2218
	 */
	function testGutenbergExcerptOption() {
		global $wp_version;
		if ( $wp_version < 5.0 ) {
			$this->markTestSkipped('Only applies to Block editor which is avaialble in WP 5.x');
		}
		$content_1 = '<!-- wp:paragraph -->
<p>Heres the start to a thing</p>
<!-- /wp:paragraph -->

<!-- wp:more {"noTeaser":true} -->
<!--more-->
<!--noteaser-->
<!-- /wp:more -->

<!-- wp:paragraph -->
<p>Heres the read more stuff that we shant see!</p>
<!-- /wp:paragraph -->';
		$post_id = self::factory()->post->create(['post_content' => $content_1 ]);
		$post = new \Timber\Post($post_id);

		$this->assertEquals('<p>Heres the read more stuff that we shant see!</p>', trim($post->content()));
	}

}