コード例 #1
0
 /**
  * Test "Edit and save a scheduling"
  */
 public function testEditSave()
 {
     //DataFixtures create 4 records
     $this->loadFixtures(array('JMose\\CommandSchedulerBundle\\Fixtures\\ORM\\LoadScheduledCommandData'));
     $client = parent::createClient();
     $client->followRedirects(true);
     $crawler = $client->request('GET', '/command-scheduler/detail/edit/1');
     $buttonCrawlerNode = $crawler->selectButton('Save');
     $form = $buttonCrawlerNode->form();
     $form->get('command_scheduler_detail[name]')->setValue('edited one');
     $crawler = $client->submit($form);
     $this->assertEquals(4, $crawler->filter('a[href^="/command-scheduler/action/toggle/"]')->count());
     $this->assertEquals("edited one", trim($crawler->filter('td')->eq(1)->text()));
 }
 /**
  * call a URL, follow redirects
  *
  * @param string $method GET|POST
  * @param string $url URL
  * @param string $return crawler|response to return either a \Symfony\Component\DomCrawler\Crawler or a \Symfony\Component\HttpFoundation\Response
  *
  * @return mixed
  */
 protected function callUrl($method, $url, $return = 'crawler')
 {
     $client = parent::createClient();
     $client->followRedirects(true);
     $crawler = $client->request($method, $url);
     $response = $client->getResponse();
     return ${$return};
 }
コード例 #3
0
 public static function createClient(array $options = [], array $server = [])
 {
     $server['HTTP_Authorization'] = base64_encode('test_token:');
     return parent::createClient($options, $server);
 }
コード例 #4
0
 /**
  * Test monitoring URL with json
  */
 public function testMonitorWithoutErrors()
 {
     //DataFixtures create 4 records
     $this->loadFixtures(array('JMose\\CommandSchedulerBundle\\Fixtures\\ORM\\LoadScheduledCommandData'));
     $two = $this->em->getRepository('JMoseCommandSchedulerBundle:ScheduledCommand')->find(2);
     $four = $this->em->getRepository('JMoseCommandSchedulerBundle:ScheduledCommand')->find(4);
     $two->setLocked(false);
     $four->setLastReturnCode(0);
     $this->em->flush();
     $client = parent::createClient();
     $client->followRedirects(true);
     // One command is locked in fixture (2), another have a -1 return code as lastReturn (4)
     $client->request('GET', '/command-scheduler/monitor');
     $this->assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode());
     $jsonResponse = $client->getResponse()->getContent();
     $jsonArray = json_decode($jsonResponse, true);
     $this->assertEquals(0, count($jsonArray));
 }