Phpunit cannot find test, No test executed(Laravel) - phpunit

I am using phpunit in laravel 5.5.
When I run test using
vendor/bin/phpunit .
it shows the error
no tests excucted.
In phpunit.xml file I set suffix of test directories.
But I don't know what is the problem.

Can u share more details of your work ? If you are new in laravel can follow: https://www.youtube.com/watch?v=3uYXAcit_Sg&list=PL3VM-unCzF8iPERY07XRw0JXG_c50CapR . there is step by step guideline

I solved the problem.
The solution is here:
https://phpunit.readthedocs.io/en/7.1/installation.html#windows

I write this in case someone from Laravel 8 come and found the similar error.
Today I learn about TDD and follow a tutorial in Youtube. in one phase I create a test function with similar name as the tutorial explained,
.
But then come the error "No Test Executed!" appear.
Similar to this question.
I already check and make sure that the file name is suffix-ed with 'Test' word.
.
I don't know whats wrong. But then After digging around, it turns out that in Laravel 8 (or maybe prior version also), the test FUNCTION NAME have to be prefixed with Test.
e.g.
public function check_family() => won't work
public function test_check_family() => work

Related

How to add new column to exitsting table symfony - orocommerce

I'm working on an orocommerce project, and it use vendor/oro/bundles/bundle_name
And in that bundle, it have an entity named "oro_customer_user", so i want to add a new column in that table using my new bundles.
I've searched a lot but still no luck.
Almost of solution say i need to fix in vendor/oro/bundles/bundle_name, which i don't want to do.
But still have some solution say i need to use DoctrineMigrationsBundle but i'm not sure about this.
https://symfony.com/doc/master/bundles/DoctrineMigrationsBundle/index.html
Please give advice, thanks :)
Alright, so i've found the solution for orocommerce
Just use Migration and everything is gonna be fine
You can check in this link:
https://forum.oroinc.com/orocrm/orocrm-programming-questions/topic/add-custom-field-into-orocrm-entity#post-24765
The migrate you have to create manual, because i don't know how to create migrate by command line :( .
After create migrate done, you only need to run this cmd:
php app/console oro:migration:load --show-queries
Now go and check in database, its done already.
And about entity:
I still don't know how to custom it in orocommerce. It got a lot of error.

Wordpress plugin + phpunit testing

I am new in wordpress developement, I have my own custom wordpress plugin which allows admin to click multiple author and save all meta tag in the database on post. It works fine. But i want to generate test case for that. I installed phpunit but I don't know how to write test case.
public function testOne()
{
$this->factory->post->create();
}
I tried this but not understand how it works.
It's not difficult but it's definitely not trivial. You'll need to set up a test Wordpress database just for PHPUnit to run tests
I found these guides really useful:
https://codesymphony.co/writing-wordpress-plugin-unit-tests/
https://engineering.hmn.md/guides/writing-code/writing-tests/
In order to get the files that PHPUnit needs to set up a WordPress testing environment, I had to get a new WordPress directory:
https://core.trac.wordpress.org/browser/trunk?order=name
And I was stymied for a while by MySQLi failing as soon as my unit tests started, but fixed it with a setting change after reading this:
https://core.trac.wordpress.org/ticket/39327
And now I can actually fix the bugs that the Unit Testing found :).
First of all, you should use the WordPress modules for Codeception, which includes the PHPunit WPTestCase and many other tools.
There are two basic approaches to testing something like this in WordPress:
You can test it with a browser. This is called an acceptance test. You list all the actions that prove the concept you are testing, and you run a browser [or browser simulator] to do the task step by step. You can look into the database for the artifacts you expect to see as a result, and prove it happens correctly. In your case, you might want to setup some posts, click the multiple authors, and then check the database for the meta tags you expect. It might look something like:
$I = /*am a */ new AcceptanceTester($scenario);
$I->loginAsAdmin();
$I->amOnPage("/wp-admin/post-new.php");
$I->fillField('#content', "lorum ipsum");
$I->click('#publish');
The other approach is to encapsulate your action in an OOP class, and test it using the WPUnit test tools. Codeception uses the same PHPUnit library the WordPress core teams uses, plus a bunch of other tools. The WPUnit approach loads a database into memory, and can do things like setup dummy posts for your plugin to work on. So in your case, you might have a class:
class SystemActionSaveMetaTags{
public function doSaveMetaTags()
}
You might have a test called
itShouldSaveMetaTags(){
$id = wp_insert_post();
$SystemActionSaveMetaTags = new SystemActionSaveMetaTags;
$SystemActionSaveMetaTags->doSaveMetaTags($id);
$this->assertTrue($this->checkForCorrectMetaTags($id));
}
Here is a tutorial on the subject, as it relates to WordPress:
https://wp-bdd.com/wp-codeception-tutorial/

Nelmio/Alice 2.x Symfony 3 , Loading Related Fixtures in Different Bundles

If there's already answer to my question then sorry and please point me in the right direction because I can't find anything.
Let's say I have two Bundles. Each bundle has fixures.yml file and loader file.
Loaders and fixtures are working fine when they are not depending on each other.
However when I am referencing fixtureA from fixtureB I get duplicated record in database.
E.g:
user_{1..10}:
email (unique): '<firstName()>+<randomNumber()>#gmail.com'
plainPassword: 'secret'
story_{1..10}:
user: "#user_<current()>"
title: '<word>'
When they are in separated files - duplicated row. When they are in the same file everything is ok.
Why it's being loaded twice?
I even tried this:
$objects = Fixtures::load(__DIR__ . '/fixtures.yml', $manager, ['persist_once'=>true]);
No luck.
Evey time I am trying to use user object in story fixtures alice tries to save it into db again.
Best Regards,
Robert
I did a little research and talked to people - it looks like it's a possible bug. You can learn more here:
Nelmio/Alice 2.x Duplicated Row
Also I would like to share my work around:
I wanted to keep things separated and clean. Instead of keeping all fixtures in one file in one bundle you can move it to App/DataFixtures/ORM directory. However Symfony will not look for fixtures in this directory. You can:
add path to the fixtures in console command:
doctrine:fixtures:load --fixtures=/var/www/story/app/DataFixtures/ORM
create alias for above solution
override DoctrineFixturesBundle - how to do this
I hope this will help if you have similar issue.

Unit tests in meteor can't find the code they need to test

I'm struggling with unit tests in Meteor. I want to use the velocity, jasmine package but I must be doing something wrong. The tests don"t seem to work because the test can't find the code to test. The test project is available on github.
The code that i want to test is here:
https://github.com/robvanpamel/coderepository/blob/master/meteor/sandwich-app/server/Services/SandwichService.js
The unit Test is here:
https://github.com/robvanpamel/coderepository/blob/master/meteor/sandwich-app/tests/jasmine/server/integration/spec/SandwichServiceSpec.js
When I uncomment the created SandwichService in the Unit Test, the test works, which is normal.
I haven't done any configuration elsewhere in meteor, and i think that is the problem. Do you have to put a package.js file where you specify your source code?
How can Jasmine know where it can find the SandwichService I'm trying to test? It is also the error i get.
"ReferenceError: SandwichesService is not defined "
EDIT
I was able to resolve it and updated the code repository in GitHub. The key was not to use the Javascript prototypes. so the below will not work
function SandwichesService(){};
SandwichesService.prototype.listSandwiches = function() {
// do stuff here
}
while the code below does work
SandwichService = {
listSandwiches: function(){
// do stuff here
}
};
I don't really understand why? Does somebody can tell me?
Kind regards and thanks upfront!
Rob
This is a Meteor issue not a testing issue :)
You need to put the SandwichesService on the global namespace. Your second block does that by default.
Try:
SandwichService = new SandwichesService()
(don't use var)

IfxBulkCopy class doesn't exist?

Q:
I face the following problem.
I wanna to create an object from the following class IfxBulkCopy but it doesn't appear at all.
I do the following:
1- Add a reference IBM.Data.Informix .
2- Add using IBM.Data.Informix;
but in vain .
I search in the documentation and it exists .but i can't find it .
Please help .if there is a different version or some error i made?
I think you need the Common IDS .NET provider.
Basically there are two different providers that implement classes in the IBM.Data.Informix namespace.
More info here

Resources