Unit-Testing a WooCommerce Extension - wordpress

I'm new to using PHPStorm along with PHPUnit, and the wordpress-develop package.
My projects rely on WooCommerce a lot.
Is it possible to add it as a dependency to the project?
At the moment I get this result:
And have the following setup:
Any help appreciated.

Got it working
What I did was use git to clone the woocommerce project
git clone https://github.com/woocommerce/woocommerce/ temp
Then I copied the tests folder and put it inside my project. Then I kept making edits until it worked with my existing code.
Here is what my project looks like now:
I have a copy of the normal woocommerce project in my includes. The one without the tests, the one you can download from the WordPress plugin repository.
I copied the WooCommerce tests into the project, see folder wc_tests.
Here is what the tests/bootstrap.php file looks like
Note the last line that requires the wc_tests/bootstrap.php file.
I only made one change to the wc_tests file, I changed the plugin directory.
$this->plugin_dir = dirname( $this->tests_dir ) . '/includes/woocommerce';
Combined with a line of code out of screen, it makes the WC available for the project
require_once $this->plugin_dir . '/woocommerce.php';
I'm probably doing some of this wrong, but it works.
Any further questions, tips or advice appreciated.

Related

Netbeans step through out of project tree files for debugging (PHP)

I am writing a Wordpress plugin that depends on another plugin with netbeans.
The project is just containing the files of my plugin and I want to keep it that way to have a clean git repository.
The problem:
I rely on another plugin and want to understand how that plugin works. For this, I want to "step through" the other plugin.
I want to do this on my localhost configuration.
I have basically two destinations:
The project is in my home directory in my github folder
The server files are under c:\wamp64\www\wordpress ...., where the localhost is running
The project is essentially set up correctly to copy files from my github directory to the localhost path (Properties -> Sources)
Then:
I set an include path to the localhost -> wordpress folder in the project properties, and when I now search for a definition in my code that refers to the other plugin, the corresponding file is opened (did not work before setting the include path)
Debugging essentially works, but when I step into a function of the other plugin, the bar becomes grey and the corresponding file is not opened.
Can I change some setting for netbeans to open up the other file (not in the project tree) and step through it?
I have found a reasonable workaround.
I just created a new PHP project in Netbeans with existing sources.
As source, I used the entire wordpress installation in the wamp server path, i.e. c:\wamp64\www\wordpress
I can now 'debug' and step through this new project, but I also need to add the corresponding breakpoints in the files from the server path.
It requires some discipline as I have to open the files from my plugin twice, once in the server path and once in the project path, but only edit the files in the project path.
It works 'ok', but I would still be interested to hear if someone has a more proper solution to this.

Where to put the live-search-docs config file in all in one alfresco project?

I have been going through some blog posts that tell how to customize the live search . What is not clear to me is where should I place the live-search-docs.get.config.xml file in my all-in-one-share project so that it is bootstrapped and deployed in the correct location.
Please can some one advise where the file should be placed in my all-in-one alfresco project?
From the link below
https://www.bluefishgroup.com/insights/ecm/adding-metadata-fields-to-simple-search-and-live-search-with-alfresco-5/
they suggest the search query customization file to be placed under
These files can now be modified to add additional metadata fields as
needed. Once the files have been updated, they should be deployed to
the ‘extensions’ directory so that they will override the out of the
box configuration. If you are deploying your code as a custom AMP
file, the files should target the following directory:
tomcat/webapps/alfresco/WEB-INF/classes/alfresco/extension/templates/webscripts/org/alfresco/slingshot/search
if my file needs to end up in the above path in my WAR, where exactly should I place the search file in my all-in-one alfresco project so that its deployed to the above folder? I would like this to be bootstrapped with my all in one project. I tried putting the file under src/main/resources/alfresco/site-webscripts with the remaining path for the file but that did not work.
Thanks
The easiest way is to create a copy of that file in:
my-all-in-one-project-platform-jar/src/main/resources/alfresco/extension/templates/webscripts/org/alfresco/slingshot/search/
where, of course, my-all-in-one-project-platform-jar must be substituted with the name that you have specified when the project was created with the all-in-one archetype.
The file in the extension subpath will override the corresponding OOTB files.
See Web scripts

Don't delete specific files during asp.net publish?

I have a website I'm publishing in Visual Studio. It's publishing using the File System method, and I've selected the option to delete all existing files before publish.
Is there a method that will exclude two specific files from deletion? Both of these files exist in the root of the website folder.
I've tried editing the .pubxml file that is created by Visual Studio to include a "MsDeploySkipRules" option but it never seems to work, no matter what settings I've selected. I've also tried to turn "UsMsDeployExe" on and noticed no difference.
I am sorry I don't have the exact answer for what you have asked.
But there is a work around to achieve what you want. see if this helps
You can include those 2 files into your solution and then set the properties
Build Action = content
Copy to output Directory = Always
This way you will always gets same copies in your publishing directory
Hope this helps!
If you find answer helpful please up vote
Thanks
Mohan!

How to find /mysite/ folder - SilverStripe CMS

I'm having some trouble finding my /mysite/ folder - I'm trying to edit my _config.php file so I can add some schema to a website however, there is no /mysite/ folder. Is it possible it was renamed something else, or simply doesn't exist? Is there a way I can find out which folder is the "/mysite/" folder?
The global variable $project is defined with the name of the "mysite" folder (it's basically the project folder).
So echoing that out from ContentController::init() would be a good way to determine it. Otherwise, just search the folders for "Page_Controller" and you should find the page class and where all the other work is stored.
global $project;
var_dump($project);
die;
It should be in your webroot, where also a /framework/ and a /cms/ folder should be. Look at the webserver configuration to find out where the root of your website is located.
How did you install silverstripe? Did you use composer? Did you download a ready-to-use zip? If yes, which one?

The ELGG Themes Pluigins show This plugin is invalid: The required file "start.php" is missing. error

Hi I'm new to Elgg framework i'm looking for change the themes of the my site, i have used sea themes,pab_theme,puritythree_theme, and i was open the pluigins in admin page, i can't activated the themes
seatheme
This plugin is invalid: The required file "start.php" is missing.
Check the Elgg documentation for troubleshooting tips
the above message was show, so how can i will change the themes
Every plugin (and themes are plugins) needs to have a start.php file in the root of the plugin's directory. So the path should look something like:
Elgg/mod/seatheme/start.php
The theme needs to reside in the mod dir, and it must have a start file. If, for some reason it doesn't, then you would get that error.
Are you really trying to load three themes? Generally people only load one. I don't think that this is the cause of the error though.
It would be good if you spent some time with the Elgg documentation, specifically: http://docs.elgg.org/wiki/Themes
I had the same problem but I found the solution. You have to download the zip file of the theme, unzip the file, open the file and if you find another file inside you must send that file to the mod file. Basically the directory would be Theme->Theme-> The rest of the files with start.php in it.
So you would have to send the second folder to the mod folder.

Resources