我正在尝试为我的web应用程序编写一些单元测试。我使用Laravel 5.3和Mockery。
这是简化的代码:
class UserService
{
protected $userRepository;
public function __construct(IUserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function saveUserWithGeneratedPassword($user, $com
我正在试着测试一个控制器。Zend工具生成了以下代码:
class Default_CarrinhoControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
{
public function setUp()
{
$this->bootstrap = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
parent::setUp();
}
public function t
-这是我的AddItemTest.php代码,我想要post到路由"products“函数存储 namespace Tests\Feature;
use App\Models\Employee;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
use function PHPSTORM_META\map;
class AddItemTest extends TestCase
{
use Refr
我在phpunit上遇到了一个问题,我将路由设计为
/v1/outlet/{outlet_id}/test
Route::get('outlets/{outlet_id}/test', ['as' => 'test'], function(){
return app('request')->route('outlet_id');
});
当我在postman或brower中调用它时,它可以工作,但在phpunit中显示为错误
Call to a member function paramet
我现在有个奇怪的问题。
我目前正在构建一个Laravel,它在的Github上。我使用来单独测试这个包以及它的BrowserKit扩展。
当我在本地运行测试套件时,它可以正常工作。然而,在Travis CI中,它引发以下错误:
Error: Class 'Route' not found in /home/travis/build/matthewbdaly/laravel-error-snapshot/src/routes.php on line 3
因此,我尝试在routes.php中显式导入路由外观。同样,它只在本地工作,但它返回了另一条错误消息:
PHP Fatal e
我正在尝试在Laravel5.1中创建一个测试,但是我想在没有授权表的情况下使用它。
在我的RoleController类中,我这样做是为了:
public function __construct()
{
$this->middleware('auth');
}
我试过使用use WithoutMiddleWare;,但没有起作用。这是phpunit输出:
A request to [http://localhost/nuevo/rol] failed. Received status code [500].
也尝试过对每个测试方法使用$this->wit
我在运行Laravel,当我试图开发自动化时,有一个问题。我有以下测试:
class SubmitSurvivorTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
//Test for submit with missing parameters
public function testEmptySubmit()
{
$response = $this->get('/submit/survivor&
我编写了一个router.test.php文件:
class RouterTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
require_once '../router.class.php';
}
public function testUnit()
{
$this->assertEquals(true, true);
}
}
..。只需测试我的PHPUnit库是否正常工作。但是,当我在控制台中输入ph
在我的PHPUnit文件中有一个测试路由的测试文件夹中有一个带有indexTest.php的测试文件夹,是否有一种使用index.php的方法?
无脂指南给出了模拟路由请求和帖子的代码片段。只有当我在测试文件中直接生成包含任何功能的路由时,我才能让这样的测试正常工作。
我想要的是用令牌模拟一个路由,允许它从index.php中的一个路由运行,并通过控制器和测试应该通过运行路由来设置的f3变量。
<?php
class indexTest extends \PHPUnit_Framework_TestCase
{
public function test()
{
嗨,我有这个页面,它是/dno-personal/cebu-properties。我试着在我的laravel中使用PHPUNIT测试。现在我在下面创建了这个测试文件
<?php
namespace Tests\Feature;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions
我正在尝试使用PHPUnit / Integrated进行功能测试。
所以,我需要的是生成一个假对象,并填充我表单中的所有字段。
问题是,当我试图用Faker生成一个人时,我会得到以下错误消息:
PHP Fatal error: Call to a member function make() on null in /home/vagrant/RH/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 62
PHP Stack trace:
PHP 1. {main}() /home/vagrant/
我希望测试端点注册(您可以将注册视为注册),同时我希望返回响应对象并重定向用户登录端点,但是当我运行测试时,它会出现这个错误。
• Tests\Unit\ProjectTest > http
Failed asserting that two strings are equal.
at C:\xampp\htdocs\test\tests\Unit\ProjectTest.php:49
45▕ 'Select'=>'Software Engneering',
46▕ &
我有一个在命名空间中创建的程序的测试程序。我遇到的问题是,laravel容器似乎没有解决测试方法依赖关系,也没有解决laravel,.。我在Windows 10上。
PHP代码:
<?php
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ACME\SomeClass;
class CLIComman