Example #1
0
 public function testPetitionsLists()
 {
     $this->open('userPage/petitions/1');
     $this->waitForPresent($this->getCssSel('container'));
     $this->waitForPresent($this->getCssSel('myPetitions.petitionsFeed'));
     $this->waitForPresent($this->getCssSel('petitionsForMe.petitionsFeed'));
     $this->assertPetitionsTotalCountIs($count = 15, 'petitionsForMe');
     $this->assertPetitionsOnPageCountIs($count, 'petitionsForMe');
     $this->assertPetitionsTotalCountIs($count = 16, 'myPetitions');
     $this->assertPetitionsOnPageCountIs($count, 'myPetitions');
     $petitions = Petition::model()->findAllByAttributes(array('creator_id' => 1));
     $this->assertPetitionsFeedContains($petitions, 'myPetitions');
     $petitions = Petition::model()->findAllByAttributes(array('mandate_id' => Mandate::model()->getUsersMandates(1)));
     $this->assertPetitionsFeedContains($petitions, 'petitionsForMe');
     $this->open('userPage/petitions/2');
     $this->waitForPresent($this->getCssSel('container'));
     $this->waitForPresent($this->getCssSel('petitionsFeed'));
     $this->assertElementNotPresent($this->getCssSel('myPetitions'));
     $this->assertElementNotPresent($this->getCssSel('petitionsForMe'));
     $this->assertPetitionsTotalCountIs(0);
     $this->assertElementContainsText($this->getCssSel('petitionsFeed.item'), 'There is no items.');
 }
Example #2
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Petition::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 protected function createPetition()
 {
     $this->waitForPresent($this->getCssSel('container'));
     $this->assertElementPresent($this->getCssSel('tabs.createPetition'));
     $this->click($this->getCssSel('tabs.createPetition'));
     $this->waitForPresent($this->getCssSel('newPetitionForm'));
     $newPetitionTitle = 'New petition ' . time();
     $newPetitionText = $newPetitionTitle . ' text here.';
     $this->type($this->getCssSel('newPetitionForm') . ' input[name="Petition[title]"]', $newPetitionTitle);
     $this->type($this->getCssSel('newPetitionForm') . ' textarea', $newPetitionText);
     $this->click($this->getCssSel('newPetitionForm') . ' input.btn[type="submit"]');
     $this->waitForVisible($this->getCssSel('petitionsFeed'));
     $this->waitForElementContainsText($this->getCssSel('petitionsFeed.item.title'), $newPetitionTitle);
     $petition = Petition::model()->findByAttributes(array('title' => $newPetitionTitle));
     return $petition;
 }