Passed
Push — master ( ef81d9...bd9122 )
by Adekunle
03:43
created

RestApiTest::testStore()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Crystoline\LaraRestApi\Tests;
4
5
use Tests\TestCase;
6
use Illuminate\Foundation\Testing\RefreshDatabase;
7
8
class RestApiTest extends TestCase
9
{
10
    use RefreshDatabase;
0 ignored issues
show
introduced by
The trait Illuminate\Foundation\Testing\RefreshDatabase requires some properties which are not provided by Crystoline\LaraRestApi\Tests\RestApiTest: $connectionsToTransact, $dropViews
Loading history...
11
    /**
12
     * A basic test example.
13
     *
14
     * @return void
15
     */
16
    public function testStore()
17
    {
18
        $response = $this-action('POST', 'Crystoline\LaraRestApiTestController@yourAction', ['links' => 'link1 \n link2']);
0 ignored issues
show
Bug introduced by
array('links' => 'link1 \n link2') of type array<string,string> is incompatible with the type boolean expected by parameter $absolute of action(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

18
        $response = $this-action('POST', 'Crystoline\LaraRestApiTestController@yourAction', /** @scrutinizer ignore-type */ ['links' => 'link1 \n link2']);
Loading history...
19
        // you can check if response was ok
20
        $this->assertTrue($response->isOk(), "Custom message if something went wrong");
0 ignored issues
show
Bug introduced by
The method isOk() does not exist on integer. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

20
        $this->assertTrue($response->/** @scrutinizer ignore-call */ isOk(), "Custom message if something went wrong");

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
21
        // or if view received variable
22
        $this->assertViewHas('links', ['link1', 'link2']);
0 ignored issues
show
Bug introduced by
The method assertViewHas() does not exist on Crystoline\LaraRestApi\Tests\RestApiTest. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
        $this->/** @scrutinizer ignore-call */ 
23
               assertViewHas('links', ['link1', 'link2']);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
23
    }
24
}
25