|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Created by PhpStorm. |
| 4 | + * User: alexboyce |
| 5 | + * Date: 4/2/17 |
| 6 | + * Time: 12:45 PM |
| 7 | + */ |
| 8 | + |
| 9 | +class TestControllerTest extends \Symfony\Bundle\FrameworkBundle\Test\WebTestCase |
| 10 | +{ |
| 11 | + protected static $class = '\Curiosity26\AngularMaterialBundle\Tests\AppKernel'; |
| 12 | + |
| 13 | + public function testTextAction() |
| 14 | + { |
| 15 | + $client = static::createClient(); |
| 16 | + $crawler = $client->request('GET', '/test/text'); |
| 17 | + |
| 18 | + $this->assertEquals('200', $client->getResponse()->getStatusCode()); |
| 19 | + |
| 20 | + $container = $crawler->filter("form md-input-container"); |
| 21 | + |
| 22 | + $this->assertNotEmpty($container); |
| 23 | + |
| 24 | + $label = $container->filter('label'); |
| 25 | + |
| 26 | + $this->assertEquals('Test', $label->text()); |
| 27 | + |
| 28 | + $input = $container->filter('input'); |
| 29 | + |
| 30 | + $this->assertEquals(['text'], $input->extract(['type'])); |
| 31 | + } |
| 32 | + |
| 33 | + public function testRadioAction() |
| 34 | + { |
| 35 | + $client = static::createClient(); |
| 36 | + $crawler = $client->request('GET', '/test/radio'); |
| 37 | + |
| 38 | + $this->assertEquals('200', $client->getResponse()->getStatusCode()); |
| 39 | + |
| 40 | + $input = $crawler->filter("form md-radio-group md-radio-button"); |
| 41 | + $this->assertNotEmpty($input); |
| 42 | + $this->assertEquals(['test1'], $input->eq(0)->extract(['value'])); |
| 43 | + $this->assertEquals('Test 1', trim($input->eq(0)->text())); |
| 44 | + $this->assertEquals(['test2'], $input->eq(1)->extract(['value'])); |
| 45 | + $this->assertEquals('Test 2', trim($input->eq(1)->text())); |
| 46 | + } |
| 47 | + |
| 48 | + public function testCheckboxAction() |
| 49 | + { |
| 50 | + $client = static::createClient(); |
| 51 | + $crawler = $client->request('GET', '/test/checkbox'); |
| 52 | + |
| 53 | + $this->assertEquals('200', $client->getResponse()->getStatusCode()); |
| 54 | + |
| 55 | + $input = $crawler->filter("form md-checkbox-group md-checkbox"); |
| 56 | + $this->assertNotEmpty($input); |
| 57 | + $this->assertEquals(['test1'], $input->eq(0)->extract(['ng-yes-value'])); |
| 58 | + $this->assertEquals('Test 1', trim($input->eq(0)->text())); |
| 59 | + $this->assertEquals(['test2'], $input->eq(1)->extract(['ng-yes-value'])); |
| 60 | + $this->assertEquals('Test 2', trim($input->eq(1)->text())); |
| 61 | + } |
| 62 | + |
| 63 | + public function testSelectAction() |
| 64 | + { |
| 65 | + $client = static::createClient(); |
| 66 | + $crawler = $client->request('GET', '/test/select'); |
| 67 | + |
| 68 | + $this->assertEquals('200', $client->getResponse()->getStatusCode()); |
| 69 | + |
| 70 | + $input = $crawler->filter("form md-select md-option"); |
| 71 | + $this->assertNotEmpty($input); |
| 72 | + $this->assertEquals(['test1'], $input->eq(0)->extract(['value'])); |
| 73 | + $this->assertEquals('Test 1', trim($input->eq(0)->text())); |
| 74 | + $this->assertEquals(['test2'], $input->eq(1)->extract(['value'])); |
| 75 | + $this->assertEquals('Test 2', trim($input->eq(1)->text())); |
| 76 | + } |
| 77 | + |
| 78 | +} |
0 commit comments