Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jarednova authored Apr 6, 2020
2 parents a05f161 + 2fb2609 commit 87a7c1e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
11 changes: 6 additions & 5 deletions lib/PostType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ public function __toString() {

protected function init( $post_type ) {
$obj = get_post_type_object($post_type);
foreach ( get_object_vars($obj) as $key => $value ) {
if ( $key === '' || ord($key[0]) === 0 ) {
continue;
if ( ! empty( $obj ) ) {
foreach ( get_object_vars($obj) as $key => $value ) {
if ( $key === '' || ord($key[0]) === 0 ) {
continue;
}
$this->$key = $value;
}
$this->$key = $value;
}
}

}
9 changes: 9 additions & 0 deletions tests/test-timber-post-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ function testPostTypeProperty(){
$this->assertEquals('post', $post->post_type);
}

/**
* @ticket #2111
*/
function testNonExistentPostType() {
$post_type = new Timber\PostType('foobar');
$this->assertEquals('foobar', $post_type->slug);
$this->assertEquals('Timber\PostType', get_class($post_type));
}

function testPostTypeMethodInTwig() {
$post_id = $this->factory->post->create();
$post = new TimberPost($post_id);
Expand Down
10 changes: 5 additions & 5 deletions tests/test-timber-theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TestTimberTheme extends Timber_UnitTestCase {
protected $backup_wp_theme_directories;

function testThemeVersion() {
switch_theme('twentysixteen');
switch_theme('twentyseventeen');
$theme = new TimberTheme();
$this->assertGreaterThan(1.2, $theme->version);
switch_theme('default');
Expand Down Expand Up @@ -72,18 +72,18 @@ function testLinkOnSubdirectoryInstall() {
}

function testThemeGet() {
switch_theme('twentysixteen');
switch_theme('twentyseventeen');
$context = Timber::context();
$output = Timber::compile_string('{{site.theme.get("Name")}}', $context);
$this->assertEquals('Twenty Sixteen', $output);
$this->assertEquals('Twenty Seventeen', $output);
switch_theme('default');
}

function testThemeDisplay() {
switch_theme('twentysixteen');
switch_theme('twentyseventeen');
$context = Timber::context();
$output = Timber::compile_string('{{site.theme.display("Description")}}', $context);
$this->assertEquals('Twenty Sixteen is a modernized take on an ever-popular WordPress layout — the horizontal masthead with an optional right sidebar that works perfectly for blogs and websites. It has custom color options with beautiful default color schemes, a harmonious fluid grid using a mobile-first approach, and impeccable polish in every detail. Twenty Sixteen will make your WordPress look beautiful everywhere.', $output);
$this->assertEquals("Twenty Seventeen brings your site to life with header video and immersive featured images. With a focus on business sites, it features multiple sections on the front page as well as widgets, navigation and social menus, a logo, and more. Personalize its asymmetrical grid with a custom color scheme and showcase your multimedia content with post formats. Our default theme for 2017 works great in many languages, for any abilities, and on any device.", $output);
switch_theme('default');
}

Expand Down

0 comments on commit 87a7c1e

Please sign in to comment.