Skip to content

Commit

Permalink
csfix styles and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitpokhrel committed Aug 12, 2017
1 parent 9663ebc commit ad3ac0e
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 168 deletions.
16 changes: 8 additions & 8 deletions css/style-dfi.css
Expand Up @@ -2,17 +2,17 @@
* @file style-dfi.css
*
* Style for dynamic featured image plugin
*
*
* Copyright (c) 2013, Ankit Pokhrel <ankitpokhrel@gmail.com, http://ankitpokhrel.com.np>
*/

.dfiAddNew {
float: left;
float: left;
margin-top: 3px;
}

.dfiRemove {
float: right;
.dfiRemove {
float: right;
}

.dfiLinks{
Expand All @@ -29,15 +29,15 @@
}

img.dfiImg {
max-width: 258px;
max-width: 258px;
}

img.dfiImg[src=""]{
display: none;
}

img.dfiImgEmpty {
display: none;
display: none;
}

.dfiLoading {
Expand Down Expand Up @@ -74,7 +74,7 @@ img.dfiImgEmpty {
border: none;
width: auto;
height: auto;
margin: 0 !important;
margin: 0 !important;
position: absolute;
top: 30%;
left: 37%;
Expand All @@ -88,4 +88,4 @@ img.dfiImgEmpty {

.dashicons:hover, .dfiFeaturedImage:hover {
color: #2ea2cc !important;
}
}
3 changes: 1 addition & 2 deletions tests/bootstrap.php
Expand Up @@ -7,8 +7,7 @@

require_once $_tests_dir . '/includes/functions.php';

function _manually_load_plugin()
{
function _manually_load_plugin() {
require dirname( __FILE__ ) . '/../dynamic-featured-image.php';
}

Expand Down
37 changes: 18 additions & 19 deletions tests/test-dynamic-featured-image-ajax.php
Expand Up @@ -5,33 +5,33 @@
*
* @group ajax
*/
class DynamicFeaturedImageAjaxTest extends WP_Ajax_UnitTestCase
{
class DynamicFeaturedImageAjaxTest extends WP_Ajax_UnitTestCase {


private $__post_id = null;

public function setUp()
{
public function setUp() {
parent::setUp();

$this->__post_id = $this->factory->post->create( [ 'post_title' => 'Dynamic Featured Image WordPress Plugin' ] );
$this->__post_id = $this->factory->post->create( [
'post_title' => 'Dynamic Featured Image WordPress Plugin',
] );
}

/**
* @covers Dynamic_Featured_Image::ajax_callback
*/
public function testAjaxCallback()
{
public function testAjaxCallback() {
$this->_setRole( 'administrator' );

$expectedOutput = '<a href="javascript:void(0)" class="dfiFeaturedImage" title="Set Featured Image"><span class="dashicons dashicons-camera"></span></a><br/>
<img src="" class="dfiImg dfiImgEmpty"/>
<div class="dfiLinks">
<a href="javascript:void(0)" data-id="' . $this->__post_id . '" data-id-local="' . ( $this->__post_id + 1 ) . '" class="dfiAddNew dashicons dashicons-plus" title="Add New"></a>
<a href="javascript:void(0)" class="dfiRemove dashicons dashicons-minus" title="Remove"></a>
</div>
<div class="dfiClearFloat"></div>
<input type="hidden" name="dfiFeatured[]" value="" class="dfiImageHolder" />';
<img src="" class="dfiImg dfiImgEmpty"/>
<div class="dfiLinks">
<a href="javascript:void(0)" data-id="' . $this->__post_id . '" data-id-local="' . ( $this->__post_id + 1 ) . '" class="dfiAddNew dashicons dashicons-plus" title="Add New"></a>
<a href="javascript:void(0)" class="dfiRemove dashicons dashicons-minus" title="Remove"></a>
</div>
<div class="dfiClearFloat"></div>
<input type="hidden" name="dfiFeatured[]" value="" class="dfiImageHolder" />';
$expectedOutput = preg_replace( '/\s+/', '', $expectedOutput );

$_POST['id'] = $this->__post_id;
Expand All @@ -40,20 +40,19 @@ public function testAjaxCallback()
} catch ( WPAjaxDieContinueException $e ) {
}

//it should throw exception
// it should throw exception
$this->assertTrue( isset( $e ) );

//exception message must be empty
// exception message must be empty
$this->assertEquals( '', $e->getMessage() );

$response = preg_replace( '/\s+/', '', $this->_last_response );

//should contain expected output
// should contain expected output
$this->assertContains( $expectedOutput, $response );
}

public function tearDown()
{
public function tearDown() {
unset( $this->__post_id );
}
}

0 comments on commit ad3ac0e

Please sign in to comment.