Пример #1
0
 /**
  * @depends testQueryIsProperlyGeneratedForNoteWithRelatedOwnerSearch
  */
 public function testCreateAndGetNoteById()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $fileModel = ZurmoTestHelper::createFileModel();
     $accounts = Account::getByName('anAccount');
     $user = UserTestHelper::createBasicUser('Billy');
     $occurredOnStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
     $note = new Note();
     $note->owner = $user;
     $note->occurredOnDateTime = $occurredOnStamp;
     $note->description = 'myNote';
     $note->activityItems->add($accounts[0]);
     $note->files->add($fileModel);
     $this->assertTrue($note->save());
     $id = $note->id;
     unset($note);
     $note = note::getById($id);
     $this->assertEquals($occurredOnStamp, $note->occurredOnDateTime);
     $this->assertEquals('myNote', $note->description);
     $this->assertEquals($user, $note->owner);
     $this->assertEquals(1, $note->activityItems->count());
     $this->assertEquals($accounts[0], $note->activityItems->offsetGet(0));
     $this->assertEquals(1, $note->files->count());
     $this->assertEquals($fileModel, $note->files->offsetGet(0));
 }