Skip to content

Commit

Permalink
Update tests for bw_post & bw_page shortcodes using SVG icons #26 #38 #…
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbingwide committed Feb 27, 2022
1 parent 1f40c4f commit 7bebf12
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 41 deletions.
32 changes: 16 additions & 16 deletions phpunit.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="" tests="9" assertions="43" errors="0" warnings="0" failures="0" skipped="0" time="1.271481">
<testsuite name="oik-bob-bing-wide" tests="9" assertions="43" errors="0" warnings="0" failures="0" skipped="0" time="1.271481">
<testsuite name="Tests_bw_list_dashicons" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-bw_list_dashicons.php" tests="1" assertions="2" errors="0" warnings="0" failures="0" skipped="0" time="0.309574">
<testcase name="test_bw_list_dashicons" class="Tests_bw_list_dashicons" classname="Tests_bw_list_dashicons" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-bw_list_dashicons.php" line="21" assertions="2" time="0.309574"/>
<testsuite name="" tests="9" assertions="47" errors="0" warnings="0" failures="0" skipped="0" time="1.283193">
<testsuite name="oik-bob-bing-wide" tests="9" assertions="47" errors="0" warnings="0" failures="0" skipped="0" time="1.283193">
<testsuite name="Tests_bw_list_dashicons" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-bw_list_dashicons.php" tests="1" assertions="2" errors="0" warnings="0" failures="0" skipped="0" time="0.079594">
<testcase name="test_bw_list_dashicons" class="Tests_bw_list_dashicons" classname="Tests_bw_list_dashicons" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-bw_list_dashicons.php" line="21" assertions="2" time="0.079594"/>
</testsuite>
<testsuite name="Tests_bw_plug" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-bw_plug.php" tests="1" assertions="1" errors="0" warnings="0" failures="0" skipped="0" time="0.836839">
<testcase name="test_bw_plug_banner_image_url" class="Tests_bw_plug" classname="Tests_bw_plug" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-bw_plug.php" line="23" assertions="1" time="0.836839"/>
<testsuite name="Tests_bw_plug" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-bw_plug.php" tests="1" assertions="1" errors="0" warnings="0" failures="0" skipped="0" time="1.077309">
<testcase name="test_bw_plug_banner_image_url" class="Tests_bw_plug" classname="Tests_bw_plug" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-bw_plug.php" line="23" assertions="1" time="1.077309"/>
</testsuite>
<testsuite name="Tests_oik_github" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-github.php" tests="1" assertions="1" errors="0" warnings="0" failures="0" skipped="0" time="0.029437">
<testcase name="test_github_type_is_file" class="Tests_oik_github" classname="Tests_oik_github" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-github.php" line="18" assertions="1" time="0.029437"/>
<testsuite name="Tests_oik_github" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-github.php" tests="1" assertions="1" errors="0" warnings="0" failures="0" skipped="0" time="0.013162">
<testcase name="test_github_type_is_file" class="Tests_oik_github" classname="Tests_oik_github" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-github.php" line="18" assertions="1" time="0.013162"/>
</testsuite>
<testsuite name="Tests_oik_post_page" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-oik-post-page.php" tests="4" assertions="16" errors="0" warnings="0" failures="0" skipped="0" time="0.016416">
<testcase name="test_site_url" class="Tests_oik_post_page" classname="Tests_oik_post_page" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-oik-post-page.php" line="27" assertions="4" time="0.006896"/>
<testcase name="test_bw_post_no_params" class="Tests_oik_post_page" classname="Tests_oik_post_page" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-oik-post-page.php" line="48" assertions="4" time="0.003812"/>
<testcase name="test_bw_page_no_params" class="Tests_oik_post_page" classname="Tests_oik_post_page" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-oik-post-page.php" line="67" assertions="4" time="0.002002"/>
<testcase name="test_bw_page_post_type_oik_faq" class="Tests_oik_post_page" classname="Tests_oik_post_page" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-oik-post-page.php" line="87" assertions="4" time="0.003705"/>
<testsuite name="Tests_oik_post_page" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-oik-post-page.php" tests="4" assertions="20" errors="0" warnings="0" failures="0" skipped="0" time="0.037594">
<testcase name="test_site_url" class="Tests_oik_post_page" classname="Tests_oik_post_page" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-oik-post-page.php" line="27" assertions="4" time="0.010575"/>
<testcase name="test_bw_post_no_params" class="Tests_oik_post_page" classname="Tests_oik_post_page" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-oik-post-page.php" line="48" assertions="8" time="0.019541"/>
<testcase name="test_bw_page_no_params" class="Tests_oik_post_page" classname="Tests_oik_post_page" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-oik-post-page.php" line="68" assertions="4" time="0.003459"/>
<testcase name="test_bw_page_post_type_oik_faq" class="Tests_oik_post_page" classname="Tests_oik_post_page" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-oik-post-page.php" line="88" assertions="4" time="0.004019"/>
</testsuite>
<testsuite name="Tests_shortcodes_oik_wp" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-shortcodes-oik-wp.php" tests="2" assertions="23" errors="0" warnings="0" failures="0" skipped="0" time="0.079215">
<testcase name="test_wp__example" class="Tests_shortcodes_oik_wp" classname="Tests_shortcodes_oik_wp" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-shortcodes-oik-wp.php" line="21" assertions="8" time="0.008946"/>
<testcase name="test_wp__example_bb_BB" class="Tests_shortcodes_oik_wp" classname="Tests_shortcodes_oik_wp" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-shortcodes-oik-wp.php" line="31" assertions="15" time="0.070269"/>
<testsuite name="Tests_shortcodes_oik_wp" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-shortcodes-oik-wp.php" tests="2" assertions="23" errors="0" warnings="0" failures="0" skipped="0" time="0.075534">
<testcase name="test_wp__example" class="Tests_shortcodes_oik_wp" classname="Tests_shortcodes_oik_wp" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-shortcodes-oik-wp.php" line="21" assertions="8" time="0.023622"/>
<testcase name="test_wp__example_bb_BB" class="Tests_shortcodes_oik_wp" classname="Tests_shortcodes_oik_wp" file="C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\tests\test-shortcodes-oik-wp.php" line="31" assertions="15" time="0.051912"/>
</testsuite>
</testsuite>
</testsuite>
Expand Down
9 changes: 6 additions & 3 deletions tests/data/en_GB/test_bw_page_no_params.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<a href="https://qw/src/wp-admin/post-new.php?post_type=page" title="Add New Page">
<svg aria-hidden class="svg " role="img" focusable="false" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path d="M6 15V2h10v13H6zm-1 1h8v2H3V5h2v11z" />
<svg class="svg_admin-page svg " width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<rect x="0" fill="none" width="20" height="20"/>
<g>
<path d="M6 15V2h10v13H6zm-1 1h8v2H3V5h2v11z"/>
</g>
</svg>
</a>
</a>
9 changes: 6 additions & 3 deletions tests/data/en_GB/test_bw_page_post_type_oik_faq.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<a href="https://qw/src/wp-admin/post-new.php?post_type=oik-faq">
<svg aria-hidden class="svg " role="img" focusable="false" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path d="M18 10c0-4.42-3.58-8-8-8s-8 3.58-8 8 3.58 8 8 8 8-3.58 8-8zM7.23 3.57L8.72 7.3c-.62.29-1.13.8-1.42 1.42L3.57 7.23c.71-1.64 2.02-2.95 3.66-3.66zm9.2 3.66L12.7 8.72c-.29-.62-.8-1.13-1.42-1.42l1.49-3.73c1.64.71 2.95 2.02 3.66 3.66zM10 12c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm-6.43.77l3.73-1.49c.29.62.8 1.13 1.42 1.42l-1.49 3.73c-1.64-.71-2.95-2.02-3.66-3.66zm9.2 3.66l-1.49-3.73c.62-.29 1.13-.8 1.42-1.42l3.73 1.49c-.71 1.64-2.02 2.95-3.66 3.66z" />
<svg class="svg_sos svg " width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<rect x="0" fill="none" width="20" height="20"/>
<g>
<path d="M18 10c0-4.42-3.58-8-8-8s-8 3.58-8 8 3.58 8 8 8 8-3.58 8-8zM7.23 3.57L8.72 7.3c-.62.29-1.13.8-1.42 1.42L3.57 7.23c.71-1.64 2.02-2.95 3.66-3.66zm9.2 3.66L12.7 8.72c-.29-.62-.8-1.13-1.42-1.42l1.49-3.73c1.64.71 2.95 2.02 3.66 3.66zM10 12c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm-6.43.77l3.73-1.49c.29.62.8 1.13 1.42 1.42l-1.49 3.73c-1.64-.71-2.95-2.02-3.66-3.66zm9.2 3.66l-1.49-3.73c.62-.29 1.13-.8 1.42-1.42l3.73 1.49c-.71 1.64-2.02 2.95-3.66 3.66z"/>
</g>
</svg>
</a>
</a>
9 changes: 6 additions & 3 deletions tests/data/en_GB/test_bw_post_no_params.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<a href="https://qw/src/wp-admin/post-new.php" title="Add a New Post">
<svg aria-hidden class="svg " role="img" focusable="false" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path d="M10.44 3.02l1.82-1.82 6.36 6.35-1.83 1.82c-1.05-.68-2.48-.57-3.41.36l-.75.75c-.92.93-1.04 2.35-.35 3.41l-1.83 1.82-2.41-2.41-2.8 2.79c-.42.42-3.38 2.71-3.8 2.29s1.86-3.39 2.28-3.81l2.79-2.79L4.1 9.36l1.83-1.82c1.05.69 2.48.57 3.4-.36l.75-.75c.93-.92 1.05-2.35.36-3.41z" />
<svg class="svg_admin-post svg " width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<rect x="0" fill="none" width="20" height="20"/>
<g>
<path d="M10.44 3.02l1.82-1.82 6.36 6.35-1.83 1.82c-1.05-.68-2.48-.57-3.41.36l-.75.75c-.92.93-1.04 2.35-.35 3.41l-1.83 1.82-2.41-2.41-2.8 2.79c-.42.42-3.38 2.71-3.8 2.29s1.86-3.39 2.28-3.81l2.79-2.79L4.1 9.36l1.83-1.82c1.05.69 2.48.57 3.4-.36l.75-.75c.93-.92 1.05-2.35.36-3.41z"/>
</g>
</svg>
</a>
</a>
33 changes: 17 additions & 16 deletions tests/test-oik-post-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* @package oik-bob-bing-wide
*
*
* Test the functions in shortcodes/oik-post-page.php
*/
class Tests_oik_post_page extends BW_UnitTestCase {
Expand All @@ -12,14 +12,14 @@ function setUp() : void {
//oik_require( "shortcodes/oik-post-page.php", "oik-bob-bing-wide" );
oik_do_shortcode( '[bw] ');
}


/**
* Now here's a daft thing...
* When running in batch site_url() may not be https:// even though that's what set in the 'siteurl' option.
* It all depends on whether or not the request is_ssl().
*
* home_url() on the other hand does respect the setting.
*
* home_url() on the other hand does respect the setting.
* and admin_url() tests the value in force_ssl_admin().
*
* This has now been catered for in oik-batch. So all the comparing assertions should be assertEquals.
Expand All @@ -31,7 +31,7 @@ function test_site_url() {
$site_url = site_url();
$home_url = home_url();
$this->assertEquals( $site_url, $home_url );

$force_ssl = force_ssl_admin();
$this->assertTrue( $force_ssl );
$site_url = site_url( 'wp-admin/', 'admin');
Expand All @@ -41,11 +41,12 @@ function test_site_url() {

/**
* Unit test equivalent to [bw_post]
*
*
* Note: We need to call bw_do_shortcode() in order to test oik's logic for PHP 7.1
*
*
*/
function test_bw_post_no_params() {
$this->switch_to_locale( "en_GB" );
$expected_output = '<a href="http://example.com/wp-admin/post-new.php" title="Add New Post"><span class="dashicons dashicons-admin-post "></span></a>';
$expected_output = str_replace( "http://example.com", home_url(), $expected_output );
$html = bw_do_shortcode( "[bw_post]" );
Expand All @@ -56,13 +57,13 @@ function test_bw_post_no_params() {
$this->assertArrayEqualsFile( $html );
//$this->assertEquals( $expected_output, $html );
}


/**
* Unit test equivalent to [bw_page]
*
*
* Note: We need to call bw_do_shortcode() in order to test oik's logic for PHP 7.1
*
*
*/
function test_bw_page_no_params() {
$expected_output = '<a href="http://example.com/wp-admin/post-new.php?post_type=page" title="Add New Page"><span class="dashicons dashicons-admin-page "></span></a>';
Expand All @@ -75,14 +76,14 @@ function test_bw_page_no_params() {
$this->assertArrayEqualsFile( $html );
//$this->assertEquals( $expected_output, $html );
}

/**
* Test Add FAQ
* Test Add FAQ
* [bw_page post_type=oik-faq icon=sos]
*
* Note: This may depend on the oik-faq post type being defined.
* The test should be updated for the new dashicon logic using SVG!
*
* The test should be updated for the new dashicon logic using SVG!
*
*/
function test_bw_page_post_type_oik_faq() {
$expected_output = '<a href="http://example.com/wp-admin/post-new.php?post_type=oik-faq" title="Create New FAQ"><span class="dashicons dashicons-sos "></span></a>';
Expand Down

0 comments on commit 7bebf12

Please sign in to comment.