protected function setUp() { unset($this->list); parent::setUp(); $example = new \Rhubarb\Stem\Tests\Fixtures\Example(); $example->getRepository()->clearObjectCache(); $example->Forename = "John"; $example->Surname = "Joe"; $example->DateOfBirth = "1990-01-01"; $example->ContactID = 1; $example->save(); $example->Forename = "John"; $example->Surname = "Johnson"; $example->DateOfBirth = "1988-01-01"; $example->ContactID = 2; $example->save(); $example->Forename = "John"; $example->Surname = "Luc"; $example->DateOfBirth = "1990-01-01"; $example->ContactID = 3; $example->save(); $example = new \Rhubarb\Stem\Tests\Fixtures\Example(); $example->Forename = "Mary"; $example->Surname = "Smithe"; $example->DateOfBirth = "1980-06-09"; $example->ContactID = 4; $example->save(); $example = new \Rhubarb\Stem\Tests\Fixtures\Example(); $example->Forename = "Tom"; $example->Surname = "Thumb"; $example->DateOfBirth = "1976-05-09"; $example->ContactID = 5; $example->save(); $this->list = new Collection("\\Rhubarb\\Stem\\Tests\\Fixtures\\Example"); }
protected function setUp() { parent::setUp(); $example = new \Rhubarb\Stem\Tests\Fixtures\Example(); $example->getRepository()->clearObjectCache(); $example->Forename = "John"; $example->save(); $example = new \Rhubarb\Stem\Tests\Fixtures\Example(); $example->Forename = "Mary"; $example->save(); $example = new \Rhubarb\Stem\Tests\Fixtures\Example(); $example->Forename = "Tom"; $example->Surname = "Thumb"; $example->save(); $this->list = new Collection("\\Rhubarb\\Stem\\Tests\\Fixtures\\Example"); }
protected function setUp() { parent::setUp(); $example = new Example(); $example->getRepository()->clearObjectCache(); $example = new Example(); $example->Forename = "a"; $example->CompanyID = 1; $example->save(); $example = new Example(); $example->Forename = "b"; $example->CompanyID = 2; $example->save(); $example = new Example(); $example->Forename = "c"; $example->CompanyID = 3; $example->save(); }
public function testFilter() { Example::clearObjectCache(); $example = new Example(); $example->DateOfBirth = new RhubarbDateTime("last monday"); $example->save(); $example = new Example(); $example->DateOfBirth = new RhubarbDateTime("last tuesday"); $example->save(); $example = new Example(); $example->DateOfBirth = new RhubarbDateTime("last sunday"); $example->save(); $example = new Example(); $example->DateOfBirth = new RhubarbDateTime("last saturday"); $example->save(); $collection = Example::find(new DayOfWeek("DateOfBirth", [0, 1])); $this->assertCount(2, $collection); $this->assertEquals("Monday", $collection[0]->DateOfBirth->format("l")); $this->assertEquals("Tuesday", $collection[1]->DateOfBirth->format("l")); $collection = Example::find(new DayOfWeek("DateOfBirth", [0, 6])); $this->assertCount(2, $collection); $this->assertEquals("Sunday", $collection[1]->DateOfBirth->format("l")); }
public function testTransforms() { $example = new Example(); $example->DateOfBirth = "2012-10-01"; $rawData = $example->ExportRawData(); $this->assertInstanceOf("\\DateTime", $rawData["DateOfBirth"]); $this->assertEquals("1st October 2012", $rawData["DateOfBirth"]->format("jS F Y")); $dob = $example->DateOfBirth; $this->assertInstanceOf("\\DateTime", $dob); $this->assertEquals("1st October 2012", $dob->format("jS F Y")); $example->DateOfBirth = "2012-10-02"; $rawData = $example->ExportRawData(); $this->assertInstanceOf("\\DateTime", $rawData["DateOfBirth"]); $this->assertEquals("2nd October 2012", $rawData["DateOfBirth"]->format("jS F Y")); $dob = $example->DateOfBirth; $this->assertInstanceOf("\\DateTime", $dob); $this->assertEquals("2nd October 2012", $dob->format("jS F Y")); $example->DateOfBirth = mktime(0, 0, 0, 10, 3, 2012); $this->assertEquals("3rd October 2012", $example->DateOfBirth->format("jS F Y")); $example->DateOfBirth = new \DateTime("2012-01-01"); $this->assertEquals("1st January 2012", $example->DateOfBirth->format("jS F Y")); $example->DateOfBirth = "now"; $this->assertEquals(date("jS F Y"), $example->DateOfBirth->format("jS F Y")); }
public function testModelCanBeCloned() { $contact = new Example(); $contact->save(); $newContact = clone $contact; $this->assertTrue($newContact->isNewRecord()); }