1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- use Laravel\Fluent;
- class FluentTest extends PHPUnit_Framework_TestCase {
- /**
- * Test the Fluent constructor.
- *
- * @group laravel
- */
- public function testAttributesAreSetByConstructor()
- {
- $array = array('name' => 'Taylor', 'age' => 25);
- $fluent = new FLuent($array);
- $this->assertEquals($array, $fluent->attributes);
- }
- /**
- * Test the Fluent::get method.
- *
- * @group laravel
- */
- 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);
- }
- 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('Laravel\\Fluent', $fluent->programmer());
- }
- }
|