Hi @almcr Thanks for the shout-out, regarding Testing a Theme for Gutenberg. There is an alternative approach available. A couple of days after I published the above article Rich Tabor came out with a nice plugin called Block Unit Test .
Thread Starter
almcr
(@almcr)
I did see that plugin. I downloaded it, activated it and have not figured out how to make it work yet. Rich states that it should create a Block Unit Test page, not for me, not sure why. Now I am using an old XP system with out-dated level of Chrome, perhaps that is why. Still working on that.
Al
Hi Al,
Have installed the plugin few moments ago. It did create a page (draft) with all the Gutenberg test content. Nice!
I’m using a simple basic theme with a basic stylesheet and I notice Gutenberg itself provides most of the custom styling (CSS). So the Gutenberg test page looks just fine on my test site. I thought theme developers had to make lots of CSS changes to support Gutenberg, but it seems that Gutenberg itself already provides most of it.
Guido
Thread Starter
almcr
(@almcr)
that’s good Guido. I have no doubt that the plugin works, it is just that it does not work for me on my computer. I do not know why and have been trying to figure out why since I first installed the plugin. I tried it again not five minutes ago. I am using an old XP system with XAMPP, running php 5.3.5, wordpress 4.9.7.
I looked at the code in the plugin and have extracted the code that the plugin generates and have put that into a page and have displayed the output. All of that works fine, it is just that no page is generated when I activate the plugin. The only way for me to get content out of the plugin is to copy and paste it.
still searching for an answer
Al
Thread Starter
almcr
(@almcr)
if I put this code into the plugin’s class-block-unit-test.php file at line 31
//output some debug string
error_log( ‘executing Block Unit Test code’ );
then turning on debug mode does show that the plugin code is being executed, is there any way to show the ‘content’ of the page that is supposed to be created for me? which php line code creates the actual page to be created? is there any way for me to check that that code is being executed and why the page data is not being created correctly for me?
still trying to figure out why this plugin is not working for me, and it does work for other users
Al
Thread Starter
almcr
(@almcr)
found the problem with the plugin??.
I discovered that, when I initially set out to test this plugin, I created a page called Block Unit Test but in reading the documentation more carefully realized that the plugin creates the page, not I. So I deleted it and it went into Trash. Subsequent tests of the plugin still did not work, so finally today I deleted the page previously created that was in Trash. Then the plugin worked and creates the Block Unit Test page as expected.
Logic in the plugin bypasses creation of the page if already present, I guess I assumed that if the page was in Trash that the already being present condition would not be met, bad assumption.
Al
Yes, no page is created when it’s already present.
Checked file class-block-unit-test and found this:
// Do not create the post if it's already present.
if ( post_exists( $title ) ) {
return;
}
π
Guido
Thread Starter
almcr
(@almcr)
Guido,
That is true,
I guess I did not expect that a page in Trash would meet that condition. Assumptions get you every time.
Al
This topic has turned to discussing a whole other plugin, as such I’ll be closing it at this time.
If you are looking for further help with the above mentioned plugin, please use their support forums at https://wordpress.org/support/plugin/block-unit-test/