小编Shi*_*hiv的帖子

Laravel 5.4断言发送的邮件不起作用

我正试图断言用Laravel 5.4伪造的邮件.

我的测试代码是这样的:

public function setUp()
{
    parent::setUp();

    $this->admin = create(User::class, [
        'is_admin' => true,
    ]);

    $this->faker = Factory::create();
}

/** @test */
public function only_super_admin_can_create_admin()
{
    $admin = [
        'name'  => $this->faker->name,
        'email' => $this->faker->email,
    ];

    Mail::fake();

    $this->signIn($this->admin)
         ->post('/admins', $admin)
         ->assertRedirect('/admins');

    Mail::assertSent(NewUser::class, function ($mail) use ($admin) {
        dd($mail);
        // return $mail->hasTo($admin['email']);
    });

    $this->assertDatabaseHas('users', $admin);
}
Run Code Online (Sandbox Code Playgroud)

$mail倾销时,我得到以下内容:

App\Mail\NewUser {#722
  #user: App\Models\User {#726
    #fillable: array:6 [
      0 => "name"
      1 => "email"
      2 => "password"
      3 => "role"
      4 …
Run Code Online (Sandbox Code Playgroud)

php testing unit-testing laravel laravel-5

5
推荐指数
1
解决办法
1919
查看次数

Laravel 测试用例测试重定向到某个路由

我正在使用 PHPUnit 为我的 Laravel 应用程序编写一些测试用例。

下面是产生错误的类:

<?php

namespace Test\Feature;

use Tests\TestCase;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;

class UserLoginTest extends TestCase
{
    use DatabaseMigrations;

    public function setUp()
    {
        parent::setUp();
        $this->admin = factory(User::class)->create([
                'is_admin'  => true,
                'password'  => bcrypt('secret'),
            ]);
    }

    /** @test */
    public function test_login_user_form()
    {
        $this->get('/login')
            ->assertStatus(200);
    }

    /** @test */
    public function test_login_user_form_submission()
    {
        $this->post('/login', [
                'email'     => $this->admin->email,
                'password'  => 'secret',
            ]);

        $this->assertRedirectedTo('/');
    }
}
Run Code Online (Sandbox Code Playgroud)

问题是当我运行 PHPUnit 时出现以下错误:

PHPUnit 5.7.20 由 Sebastian Bergmann 和贡献者编写。....E .. 7 / 7 …

php phpunit unit-testing laravel laravel-5

4
推荐指数
1
解决办法
8960
查看次数

Nginx 缓存 404

我正在将 WordPress 与 Nginx 一起使用,但是每当我尝试启用静态文件缓存时,它们都会变为 404 not found。

这是我的/etc/nginx/conf.d/default.conf文件:

server {
    listen   80;
    server_name  _;

# SSL configuration
listen 443 ssl default_server;
ssl_certificate /etc/letsencrypt/live/shivampaw.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/shivampaw.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
ssl_dhparam /etc/nginx/ssl/dhparams.pem;
ssl_session_timeout 30m;
ssl_session_cache shared:SSL:10m;
ssl_buffer_size 8k;
add_header Strict-Transport-Security max-age=31536000;

    location / {
        root   /home/shivam/sites/shivampaw.com;
        index index.php  index.html index.htm;
        try_files $uri $uri/ /index.php?$args;
     }

    error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;
    }

    # redirect server error pages to the static page …
Run Code Online (Sandbox Code Playgroud)

php wordpress caching nginx

2
推荐指数
1
解决办法
3668
查看次数

PHP 使用 SQLite 测试 JSON Contains

我的 Web 应用程序使用 Laravel 和 MySQL,但对于我的测试,我在内存中使用 SQLite。

这是我在控制器中使用的代码:

$opportunities = DB::table('opportunities')
        ->whereRaw('JSON_CONTAINS(businesses, \'"' . $business . '"\')')
        ->get();
Run Code Online (Sandbox Code Playgroud)

测试时会抛出异常,因为 SQLite 没有 JSON_CONTAINS 函数。我怎样才能解决这个问题,以便我的测试通过并且不必对结构进行任何大规模更改?SQLite 是否有这样的功能或类似的功能?

谢谢

php mysql sqlite json laravel

2
推荐指数
2
解决办法
2802
查看次数

iFrameResize 未定义 - 通过 CDN 加载并在 JS 文件中

我正在尝试利用iFrame Resizer根据其内容(可以更改)调整同一域上 iFrame 的大小。

实例: https: //bronzecc.co.uk/sunday-2nd-xi/

我收到Uncaught ReferenceError: iFrameResize is not defined错误,但我检查了 iFrame,它们都通过 CDN 加载了正确的 JS,并且我还在该页面本身加载了正确的 JS。

为了初始化我正在使用的缩放器

var iframes = iFrameResize({log: true}, 'iframe');
Run Code Online (Sandbox Code Playgroud)

MCE:https://gist.github.com/shivampaw/7b1dba5326706673a782d115358eca2a

window.html

<html>
<head>
    <meta charset="UTF-8">
    <title>Window</title>
</head>
<body>
    <iframe src="iframe.html" style="width: 100%;" frameborder="0"></iframe>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.1.1/iframeResizer.contentWindow.min.js"></script>
    <script>
        iframes = iFrameResize({}, 'iframe');
    </script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

iframe.html

<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
    <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <title>102166</title>
</head>

<body>

    <div class="table-responsive"> …
Run Code Online (Sandbox Code Playgroud)

javascript wordpress iframe iframe-resizer

0
推荐指数
1
解决办法
3479
查看次数