Skip to content

Instantly share code, notes, and snippets.

@markphi2013
Created September 16, 2013 10:27
Show Gist options
  • Save markphi2013/6578961 to your computer and use it in GitHub Desktop.
Save markphi2013/6578961 to your computer and use it in GitHub Desktop.
programController test for program stats
public function mkStats()
{
return array(
'ProgramStats' => array(
'active-participant-count' => '2',
'participant-count' => '2',
'all-received-messages-count'=> '2',
'current-month-received-messages-count' => '2',
'all-sent-messages-count' => '2',
'current-month-sent-messages-count' => '2',
'total-current-month-messages-count' => '2',
'history-count' => '1',
'today-schedule-count' => '2',
'schedule-count' => '2',
'object-type' => 'program-stats',
'model-version'=> '1'
));
}
public function testProgramStats()
{
$this->mockProgramAccess();
$expected = $this->mkStats();
$this->testAction("/programs/getProgramStats.json");
//the problem is that iam trying to the testAction But it cann't even get to the getProgramStats() in the controller i need help with testAction pliz.thnx
//print_r($this->vars['program']);
// $this->assertEquals();
}
public function getProgramStats()
{
if(isset($this->params['url']['program'])){
$programUrl = $this->Program->find('first', array('conditions' => array('url'=> $this->params['url']['program'])));
$programStats = $this->Stats->getProgramStats($programUrl['Program']['database']);
$this->set(compact('programStats'));
}
}
//this is the function is the programcontroller AND below is the test that iam trying to do for it
@markphi2013
Copy link
Author

public function mkStats()
{
return array('Program' => array(
'id' => 1,
'name' => 'test2',
'url' => 'test2',
'database' => 'testdbprogram',
'created' => '2012-01-24 15:29:24',
'modified' => '2012-01-24 15:29:24'
),
'ProgramStats' => array(
'active-participant-count' => '2',
'participant-count' => '2',
'all-received-messages-count'=> '2',
'current-month-received-messages-count' => '2',
'all-sent-messages-count' => '2',
'current-month-sent-messages-count' => '2',
'total-current-month-messages-count' => '2',
'history-count' => '1',
'today-schedule-count' => '2',
'schedule-count' => '2',
'object-type' => 'program-stats',
'model-version'=> '1'
));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment