Skip to content

Commit

Permalink
CoreUpdate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy committed Feb 20, 2017
1 parent ca89083 commit 7295c02
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
4 changes: 2 additions & 2 deletions classes/Message/CoreUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class CoreUpdate extends Section {
* @param string $event The current event.
*/
public function __construct( $entries, WP_User $user = null, $event ) {
parent::__construct( $entries, $user );

$this->event = $event;

parent::__construct( $entries, $user );
}

/**
Expand Down
45 changes: 45 additions & 0 deletions tests/phpunit/tests/CoreUpdate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Required\Digest\Tests;

use \WP_UnitTestCase;
use \Required\Digest\Message\CoreUpdate as CoreUpdateMessage;

class CoreUpdate extends WP_UnitTestCase {
public function test_no_entries() {
$message = new CoreUpdateMessage( array(), null, 'core_update_success' );

$this->assertSame( '', $message->get_message() );
}

public function test_no_entries_failure() {
$message = new CoreUpdateMessage( array(), null, 'core_update_failure' );

$this->assertSame( '', $message->get_message() );
}

public function test_single_entry_success() {
$message = new CoreUpdateMessage(
array(
'100.1.0' => time(),
),
null,
'core_update_success'
);

$this->assertContains( 'has been updated automatically to WordPress 100.1.0', $message->get_message() );
}

public function test_single_entry_failure() {
$message = new CoreUpdateMessage(
array(
'100.1.0' => time(),
),
null,
'core_update_failure'
);

$this->assertContains( 'Please update your site', $message->get_message() );
$this->assertContains( 'WordPress 100.1.0', $message->get_message() );
}
}

0 comments on commit 7295c02

Please sign in to comment.