forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSupportFluentTest.php
More file actions
executable file
·75 lines (61 loc) · 1.66 KB
/
SupportFluentTest.php
File metadata and controls
executable file
·75 lines (61 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
use Illuminate\Support\Fluent;
class SupportFluentTest extends PHPUnit_Framework_TestCase {
/**
* Test the Fluent constructor.
*
* @test
*/
public function testAttributesAreSetByConstructor()
{
$array = array('name' => 'Taylor', 'age' => 25);
$fluent = new Fluent($array);
$refl = new \ReflectionObject($fluent);
$attributes = $refl->getProperty('attributes');
$attributes->setAccessible(true);
$this->assertEquals($array, $attributes->getValue($fluent));
$this->assertEquals($array, $fluent->getAttributes());
}
/**
* Test the Fluent::get() method.
*
* @test
*/
public function testGetMethodReturnsAttribute()
{
$fluent = new Fluent(array('name' => 'Taylor'));
$this->assertEquals('Taylor', $fluent->get('name'));
$this->assertEquals('Default', $fluent->get('foo', 'Default'));
$this->assertEquals('Taylor', $fluent->name);
$this->assertNull($fluent->foo);
}
/**
* Test the Fluent magic methods can be used to set attributes.
*
* @test
*/
public function testMagicMethodsCanBeUsedToSetAttributes()
{
$fluent = new Fluent;
$fluent->name = 'Taylor';
$fluent->developer();
$fluent->age(25);
$this->assertEquals('Taylor', $fluent->name);
$this->assertTrue($fluent->developer);
$this->assertEquals(25, $fluent->age);
$this->assertInstanceOf('Illuminate\Support\Fluent', $fluent->programmer());
}
/**
* Test the Fluent::__isset() method.
*
* @test
*/
public function testIssetMagicMethod()
{
$array = array('name' => 'Taylor', 'age' => 25);
$fluent = new Fluent($array);
$this->assertTrue(isset($fluent->name));
unset($fluent->name);
$this->assertFalse(isset($fluent->name));
}
}