Level 6
Make sure you add a backlash in front of Mockery::close(), or add use Mockery to the top of the file.
1 like
Hi,
I can't make Mockery work in my test classes.
The "funny" thing is that it works using thinker
Time: 470 ms, Memory: 10.00MB
There was 1 error:
1) Tests\Unit\SolariumTest::it_search_solarium_and_returns_the_results
Error: Class 'Tests\Unit\Mockery' not found
#my test class
<?php
namespace Tests\Unit;
use Tests\TestCase;
class SolariumTest extends TestCase
{
public function tearDown()
{
Mockery::close();
}
/** @test */
public function it_search_solarium_and_returns_the_results()
{
$client = \Mockery::mock(\Solarium\Client::class);
//$client = Mockery::mock(\Solarium\Client::class);
}
}
#using tinker
✗ php artisan tinker
Psy Shell v0.8.3 (PHP 7.0.15 — cli) by Justin Hileman
>>> $client = Mockery::mock(\Solarium\Client::class);
=> Mockery_0_Solarium_Client {#937}
>>>
#my composer
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.6.4",
"barryvdh/laravel-cors": "^0.9.2",
"barryvdh/laravel-debugbar": "^2.3",
"laravel/dusk": "^1.0",
"laravel/framework": "5.4.*",
"laravel/tinker": "~1.0",
"laravelcollective/html": "^5.4",
"solarium/solarium": "^3.8"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "~0.9.4",
"phpunit/phpunit": "~5.7"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}
Any Idea?
Thanks! :)
Please or to participate in this conversation.