Completed
Pull Request — master (#170)
by Corey
03:00
created

EditProfileFormTest::testLoadUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 21
rs 9.6666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace site\tests\unit\models;
4
5
use Yii;
6
use \site\models\EditProfileForm;
7
8
class EditProfileFormTest extends \Codeception\Test\Unit {
9
10
  public function testLoadUser() {
11
    $user = $this->getUser();
12
    $form = new \site\models\EditProfileForm($user);
13
    $form->loadUser();
14
    expect('timezone should be equal', $this->assertEquals($form->timezone, $user->timezone));
0 ignored issues
show
Bug introduced by
Accessing timezone on the interface PHPUnit\Framework\MockObject\MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
Bug introduced by
Are you sure the usage of $this->assertEquals($for...ezone, $user->timezone) targeting PHPUnit\Framework\Assert::assertEquals() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
15
    expect('email_threshold should be equal', $this->assertEquals($form->email_threshold, $user->email_threshold));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertEquals($for...$user->email_threshold) targeting PHPUnit\Framework\Assert::assertEquals() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Bug introduced by
Accessing email_threshold on the interface PHPUnit\Framework\MockObject\MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
16
    expect('partner_email1 should be equal', $this->assertEquals($form->partner_email1, $user->partner_email1));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertEquals($for... $user->partner_email1) targeting PHPUnit\Framework\Assert::assertEquals() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Bug introduced by
Accessing partner_email1 on the interface PHPUnit\Framework\MockObject\MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
17
    expect('partner_email2 should be equal', $this->assertEquals($form->partner_email2, $user->partner_email2));
0 ignored issues
show
Bug introduced by
Accessing partner_email2 on the interface PHPUnit\Framework\MockObject\MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
Bug introduced by
Are you sure the usage of $this->assertEquals($for... $user->partner_email2) targeting PHPUnit\Framework\Assert::assertEquals() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
18
    expect('partner_email3 should be equal', $this->assertEquals($form->partner_email3, $user->partner_email3));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertEquals($for... $user->partner_email3) targeting PHPUnit\Framework\Assert::assertEquals() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Bug introduced by
Accessing partner_email3 on the interface PHPUnit\Framework\MockObject\MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
19
    expect('expose_graph should be equal', $this->assertEquals($form->expose_graph, $user->expose_graph));
0 ignored issues
show
Bug introduced by
Accessing expose_graph on the interface PHPUnit\Framework\MockObject\MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
Bug introduced by
Are you sure the usage of $this->assertEquals($for...h, $user->expose_graph) targeting PHPUnit\Framework\Assert::assertEquals() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
20
    expect('send_email should be true', $this->assertTrue($form->send_email));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertTrue($form->send_email) targeting PHPUnit\Framework\Assert::assertTrue() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
21
22
    $user->email_threshold = null;
23
    $form->loadUser();
24
    expect('send_email should be false', $this->assertFalse($form->send_email));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertFalse($form->send_email) targeting PHPUnit\Framework\Assert::assertFalse() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
25
26
    $user->partner_email1 = null;
27
    $user->partner_email2 = null;
28
    $user->partner_email3 = null;
29
    $form->loadUser();
30
    expect('send_email should be false', $this->assertFalse($form->send_email));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->assertFalse($form->send_email) targeting PHPUnit\Framework\Assert::assertFalse() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
31
  }
32
33
  private function getUser() {
34
    $user = $this->getmockbuilder('\common\models\user')
35
      ->disableoriginalconstructor()
36
      ->setmethods(['getisnewrecord', 'attributes', 'save', 'findbypasswordresettoken', 'removepasswordresettoken'])
37
      ->getmock();
38
    $user->method('attributes')->willReturn([
0 ignored issues
show
Bug introduced by
The method method() does not exist on PHPUnit\Framework\MockObject\MockObject. ( Ignorable by Annotation )

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

38
    $user->/** @scrutinizer ignore-call */ 
39
           method('attributes')->willReturn([

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...
39
      'timezone',
40
      'email_threshold',
41
      'partner_email1',
42
      'partner_email2',
43
      'partner_email3',
44
      'expose_graph',
45
    ]);
46
    $user->timezone = 'America/Los_Angeles';
0 ignored issues
show
Bug introduced by
Accessing timezone on the interface PHPUnit\Framework\MockObject\MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
47
    $user->email_threshold = 10;
0 ignored issues
show
Bug introduced by
Accessing email_threshold on the interface PHPUnit\Framework\MockObject\MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
48
    $user->partner_email1 = '[email protected]';
0 ignored issues
show
Bug introduced by
Accessing partner_email1 on the interface PHPUnit\Framework\MockObject\MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
49
    $user->partner_email2 = '[email protected]';
0 ignored issues
show
Bug introduced by
Accessing partner_email2 on the interface PHPUnit\Framework\MockObject\MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
50
    $user->partner_email3 = '[email protected]';
0 ignored issues
show
Bug introduced by
Accessing partner_email3 on the interface PHPUnit\Framework\MockObject\MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
51
    $user->expose_graph = false;
0 ignored issues
show
Bug introduced by
Accessing expose_graph on the interface PHPUnit\Framework\MockObject\MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
52
    return $user;
53
  }
54
}
55