我目前正在开发Windows.
我尝试时有时会遇到问题:
git checkout origin develop
Run Code Online (Sandbox Code Playgroud)
我有这个错误:错误:无法创建文件....:权限被拒绝
"git status"显示错误的文件没有暂存,所以我必须提交
我该怎么检查?
我试图在我的电脑上执行此命令行:
chown -R username directory
Run Code Online (Sandbox Code Playgroud)
我们是几个人在git存储库上工作,他们也遇到了问题.
谢谢你的帮助
当我阅读 symfony 文档https://symfony.com/doc/current/testing.html时,他们使用以下命令初始化客户端:
$client = static::createClient();
Run Code Online (Sandbox Code Playgroud)
他们可以使用相对路径发出请求
$client->request('GET', '/post/hello-world');
Run Code Online (Sandbox Code Playgroud)
我的项目中的问题是我生成了这个网址:http://localhost/api/users但我想要的是http://myproject.localhost/api/users
我如何根据我要启动测试的环境更改基本网址(因为在我的测试环境中,我将有http://myproject.test/api/users
感谢您的帮助
在很多框架中,当您在数据库中执行请求时,您可以捕获数据库错误以抛出“用户友好”错误。
当我使用学说时,例如我插入重复值时,我收到消息“EntityManager 已关闭”并且无法继续
在尝试在学说中创建实体之前,我们是否总是必须检查重复项、外键?
例如,我在一个服务中这样做:
...
foreach ($reponse as $item) {
$item = new Item();
$item->setRelationId(item->id);
$item->setValue($item->value);
...
try {
$this->em->persist($item);
$this->em->flush();
} catch (\Exception $e) {
// Useless because if there is an exception, after this the kernel handler ends the transaction
}
}
Run Code Online (Sandbox Code Playgroud)
简单地用教义来做到这一点的好方法是什么?
谢谢
我正在拉拉韦尔开始测试
我用这个创建了一个“ .env.testing”文件
APP_NAME=myApp
APP_ENV=testing
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://myApp.localhost
DB_CONNECTION=sqlite_testing
Run Code Online (Sandbox Code Playgroud)
我将此添加到config / database.php文件的“连接”部分中
...
'sqlite_testing' => [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
],
...
Run Code Online (Sandbox Code Playgroud)
在phpunit.xml文件中,我添加了:
<env name="DB_CONNECTION" value="sqlite_testing" />
Run Code Online (Sandbox Code Playgroud)
我创建了一个UserTest功能:
class UserTest extends TestCase
{
public function setUp()
{
parent::setUp();
Artisan::call('migrate');
Artisan::call('db:seed');
}
public function tearDown()
{
parent::tearDown();
Artisan::call('migrate:reset');
}
public function testCanAccessUserSpace()
{
$user = factory(User::class)->create();
$response = $this->actingAs($user)
->get('/home');
$response->assertStatus(200);
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我运行测试时,我有:
ReflectionException: Class env does not exist
Run Code Online (Sandbox Code Playgroud)
我的配置有什么问题?
谢谢
在我的应用程序中,我使用了多重身份验证。(我使用了此链接)
它有效,并且我可以以用户身份登录->我被重定向到“ / home”
以管理员身份,登录时,我被重定向到“ / admin_home”
连接后,管理员无法访问“ / home”,他被重定向到另一个页面
但是当我编写此测试时:
class AdminTest extends TestCase
{
public function setUp()
{
parent::setUp();
Artisan::call('migrate');
Artisan::call('db:seed');
}
public function tearDown()
{
Artisan::call('migrate:reset');
parent::tearDown();
}
public function testCannotAccessUserSpace()
{
$admin = Admin::find(1);
$response = $this->actingAs($admin, 'admin')
->get('/home');
$response->assertStatus(200);
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个成功的响应,但我知道管理员无法访问“家庭”空间
我的考试有什么问题?