|
1
|
|
|
<?php declare( strict_types = 1 ); |
|
2
|
|
|
|
|
3
|
|
|
namespace Coco\SourceWatcher\Tests\Core; |
|
4
|
|
|
|
|
5
|
|
|
use PHPUnit\Framework\TestCase; |
|
6
|
|
|
use Coco\SourceWatcher\Core\Row; |
|
7
|
|
|
|
|
8
|
|
|
class RowTest extends TestCase |
|
9
|
|
|
{ |
|
10
|
|
|
public function testGetAttribute () : void |
|
11
|
|
|
{ |
|
12
|
|
|
$row = new Row( [ "name" => "Jane Doe" ] ); |
|
13
|
|
|
$expectedAttributeValue = "Jane Doe"; |
|
14
|
|
|
$this->assertEquals( $expectedAttributeValue, $row->get( "name" ) ); |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
public function testSetAttribute () : void |
|
18
|
|
|
{ |
|
19
|
|
|
$row = new Row( [ "name" => "Jane Doe" ] ); |
|
20
|
|
|
$row->set( "name", "John Doe" ); |
|
21
|
|
|
|
|
22
|
|
|
$expectedAttributeValue = "John Doe"; |
|
23
|
|
|
|
|
24
|
|
|
$this->assertEquals( $expectedAttributeValue, $row->get( "name" ) ); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function testRemoveAttribute () : void |
|
28
|
|
|
{ |
|
29
|
|
|
$row = new Row( [ "name" => "Jane Doe" ] ); |
|
30
|
|
|
$row->remove( "name" ); |
|
31
|
|
|
|
|
32
|
|
|
$expectedAttributeValue = null; |
|
33
|
|
|
|
|
34
|
|
|
$this->assertEquals( $expectedAttributeValue, $row->get( "name" ) ); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function testAccessAttributeNotationArray () : void |
|
38
|
|
|
{ |
|
39
|
|
|
$row = new Row( [ "name" => "Jane Doe" ] ); |
|
40
|
|
|
$expectedAttributeValue = "Jane Doe"; |
|
41
|
|
|
$this->assertEquals( $expectedAttributeValue, $row["name"] ); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function testAccessAttributeNotationObject () : void |
|
45
|
|
|
{ |
|
46
|
|
|
$row = new Row( [ "name" => "Jane Doe" ] ); |
|
47
|
|
|
$expectedAttributeValue = "Jane Doe"; |
|
48
|
|
|
$this->assertEquals( $expectedAttributeValue, $row->name ); |
|
|
|
|
|
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|