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-static.php
<?php

class TestTimberStaticPages extends Timber_UnitTestCase {

	function tear_down() {
		update_option('show_on_front', 'posts');
		update_option('page_on_front', '0');
		update_option('page_for_posts', '0');
	}

	function testPageAsPostsPage() {
		$pids = self::factory()->post->create_many(6);
		$page_id = self::factory()->post->create(array('post_type' => 'page'));
		update_option('page_for_posts', $page_id);
		$this->go_to(home_url('/?page_id='.$page_id));
		$page = new TimberPost();
		$this->assertEquals($page_id, $page->ID);
	}

	function testPageAsJustAPage() {
		$pids = self::factory()->post->create_many(6);
		$page_id = self::factory()->post->create(array('post_title' => 'Foobar', 'post_name' => 'foobar', 'post_type' => 'page'));
		$this->go_to(home_url('/?page_id='.$page_id));
		$page = new TimberPost();
		$this->assertEquals($page_id, $page->ID);
	}

	function testPageAsStaticFront() {
		$pids = self::factory()->post->create_many(6);
		$page_id = self::factory()->post->create(array('post_type' => 'page'));
		update_option('page_on_front', $page_id);
		$this->go_to(home_url('/'));
		global $wp_query;
		$wp_query->queried_object_id = $page_id;
		$page = new TimberPost();
		$this->assertEquals($page_id, $page->ID);
	}

	function testFrontPageAsPage() {
		$spaceballs = "What's the matter, Colonel Sandurz? Chicken?";
		$page_id = self::factory()->post->create(array('post_title' => 'Spaceballs', 'post_content' => $spaceballs, 'post_type' => 'page'));
		update_option('show_on_front', 'page');
		update_option('page_on_front', $page_id);
		$this->go_to(home_url('/'));
		$post = new TimberPost();
		$this->assertEquals($page_id, $post->ID);
	}

	function testStaticPostPage() {
		$this->clearPosts();
		$page_id = self::factory()->post->create(array('post_title' => 'Gobbles', 'post_type' => 'page'));
		update_option('page_for_posts', $page_id);
		$this->go_to(home_url('/?p='.$page_id));
		$children = self::factory()->post->create_many(10, array('post_title' => 'Timmy'));
		$posts = Timber::get_posts();
		$first_post = $posts[0];
		$this->assertEquals('Timmy', $first_post->title());
	}

	function testOtherPostOnStaticPostPage() {
		$page_id = self::factory()->post->create(array('post_title' => 'Gobbles', 'post_type' => 'page'));
		update_option('page_for_posts', $page_id);
		$post_id = self::factory()->post->create(array('post_title' => 'My Real post', 'post_type' => 'post'));
		$this->go_to(home_url('/?p='.$page_id));
		$post = new TimberPost($post_id);
		$this->assertEquals($post_id, $post->ID);
		$page = new TimberPost();
		$this->assertEquals($page_id, $page->ID);
	}

		function testRegularStaticPage() {
			$page_id = self::factory()->post->create(array('post_title' => 'Mister Slave', 'post_type' => 'page'));
			$children = self::factory()->post->create_many(10, array('post_title' => 'Timmy'));
			$this->go_to(home_url('/?p='.$page_id));
			$posts = Timber::get_posts();
			$this->assertEquals(0, count($posts));
			$page = new TimberPost();
			$this->assertEquals($page_id, $page->ID);
		}

		function testRegularStaticPageFlipped() {
			$page_id = self::factory()->post->create(array('post_title' => 'Mister Slave', 'post_type' => 'page'));
			$children = self::factory()->post->create_many(10, array('post_title' => 'Timmy'));
			$this->go_to(home_url('/?p='.$page_id));
			$page = new TimberPost();
			$this->assertEquals($page_id, $page->ID);
			$posts = Timber::get_posts();
			$this->assertEquals(0, count($posts));
		}

}