File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed
tests/phpMyFAQ/Controller Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace phpMyFAQ \Controller ;
4+
5+ use phpMyFAQ \Strings ;
6+ use phpMyFAQ \Translation ;
7+ use PHPUnit \Framework \MockObject \Exception ;
8+ use PHPUnit \Framework \TestCase ;
9+ use Symfony \Component \HttpFoundation \Response ;
10+ use Twig \Environment ;
11+
12+ class RobotsControllerTest extends TestCase
13+ {
14+ private Environment $ twig ;
15+ private RobotsController $ controller ;
16+
17+ /**
18+ * @throws Exception
19+ * @throws \phpMyFAQ\Core\Exception
20+ */
21+ protected function setUp (): void
22+ {
23+ parent ::setUp ();
24+
25+ Strings::init ();
26+
27+ Translation::create ()
28+ ->setLanguagesDir (PMF_TRANSLATION_DIR )
29+ ->setDefaultLanguage ('en ' )
30+ ->setCurrentLanguage ('en ' )
31+ ->setMultiByteLanguage ();
32+
33+ $ this ->twig = $ this ->createMock (Environment::class);
34+ $ this ->controller = new RobotsController ();
35+ }
36+
37+ /**
38+ * @throws \Exception
39+ */
40+ public function testIndex (): void
41+ {
42+ $ response = $ this ->controller ->index ();
43+
44+ $ this ->assertInstanceOf (Response::class, $ response );
45+ $ this ->assertEquals ('text/plain ' , $ response ->headers ->get ('Content-Type ' ));
46+ $ this ->assertEquals (Response::HTTP_OK , $ response ->getStatusCode ());
47+ $ this ->assertEquals ('User-agent: *\nDisallow: /admin/\nSitemap: /sitemap.xml ' , $ response ->getContent ());
48+ }
49+ }
You can’t perform that action at this time.
0 commit comments