public function testLabourCoOpPositionCalc() { $positions = $this->getAllPositions('calculateAllPolicyPositions', 'Labour'); $expectedResults = array('810' => array('policy_id' => 810, 'position' => 'voted a mixture of for and against', 'score' => 0.5, 'desc' => 'greater <b>regulation of gambling</b>')); $this->assertEquals($expectedResults, $positions); $party = new MySociety\TheyWorkForYou\Party('Labour/Co-operative'); $party->cache_position($positions['810']); $position = $party->policy_position(810); $expected = 'voted a mixture of for and against'; $this->assertEquals($expected, $position); }
<?php include_once dirname(__FILE__) . '/../www/includes/easyparliament/init.php'; $parties = MySociety\TheyWorkForYou\Party::getParties(); $policies = new MySociety\TheyWorkForYou\Policies(); $party_count = 0; foreach ($parties as $party) { $party = new MySociety\TheyWorkForYou\Party($party); $positions = $party->calculateAllPolicyPositions($policies); if (count($positions)) { $party_count++; } foreach ($positions as $position) { $party->cache_position($position); } } print "cached positions for {$party_count} parties\n";