@@ -59,4 +59,85 @@ public function test_unsupported_characters()
5959 'Your subject contains the following unsupported characters '
6060 );
6161 }
62+
63+ /**
64+ * @testdox max_quote_depth is applied to the text populating the posting form
65+ */
66+ public function test_quote_depth_form ()
67+ {
68+ $ text = '0[quote]1[quote]2[/quote]1[/quote]0 ' ;
69+ $ expected = array (
70+ 0 => '[quote="admin"]0[quote]1[quote]2[/quote]1[/quote]0[/quote] ' ,
71+ 1 => '[quote="admin"]00[/quote] ' ,
72+ 2 => '[quote="admin"]0[quote]11[/quote]0[/quote] ' ,
73+ 3 => '[quote="admin"]0[quote]1[quote]2[/quote]1[/quote]0[/quote] ' ,
74+ );
75+
76+ $ this ->login ();
77+ $ topic = $ this ->create_topic (2 , 'Test Topic 1 ' , 'Test topic ' );
78+ $ post = $ this ->create_post (2 , $ topic ['topic_id ' ], 'Re: Test Topic 1 ' , $ text );
79+ $ quote_url = "posting.php?mode=quote&f=2&t= {$ post ['topic_id ' ]}&p= {$ post ['post_id ' ]}&sid= {$ this ->sid }" ;
80+
81+ $ this ->admin_login ();
82+ foreach ($ expected as $ quote_depth => $ expected_text )
83+ {
84+ $ this ->set_quote_depth ($ quote_depth );
85+ $ crawler = self ::request ('GET ' , $ quote_url );
86+ $ this ->assertContains ($ expected_text , $ crawler ->filter ('textarea#message ' )->text ());
87+ }
88+ }
89+
90+ /**
91+ * @testdox max_quote_depth is applied to the submitted text
92+ */
93+ public function test_quote_depth_submit ()
94+ {
95+ $ text = 'depth:0[quote]depth:1[quote]depth:2[quote]depth:3[/quote][/quote][/quote] ' ;
96+ $ contains = array (
97+ 0 => array ('depth:0 ' , 'depth:1 ' , 'depth:2 ' , 'depth:3 ' ),
98+ 1 => array ('depth:0 ' , 'depth:1 ' ),
99+ 2 => array ('depth:0 ' , 'depth:1 ' , 'depth:2 ' ),
100+ 3 => array ('depth:0 ' , 'depth:1 ' , 'depth:2 ' , 'depth:3 ' ),
101+ );
102+ $ not_contains = array (
103+ 0 => array (),
104+ 1 => array ('depth:2 ' , 'depth:3 ' ),
105+ 2 => array ('depth:3 ' ),
106+ 3 => array (),
107+ );
108+
109+ $ this ->login ();
110+ $ this ->admin_login ();
111+ $ topic = $ this ->create_topic (2 , 'Test Topic 1 ' , 'Test topic ' );
112+
113+ for ($ quote_depth = 0 ; $ quote_depth <= 2 ; ++$ quote_depth )
114+ {
115+ $ this ->set_quote_depth ($ quote_depth );
116+
117+ $ post = $ this ->create_post (2 , $ topic ['topic_id ' ], 'Re: Test Topic 1 ' , $ text );
118+ $ url = "viewtopic.php?p= {$ post ['post_id ' ]}&sid= {$ this ->sid }" ;
119+
120+ $ crawler = self ::request ('GET ' , $ url );
121+ $ text_content = $ crawler ->filter ('#p ' . $ post ['post_id ' ])->text ();
122+ foreach ($ contains [$ quote_depth ] as $ contains_text )
123+ {
124+ $ this ->assertContains ($ contains_text , $ text_content );
125+ }
126+ foreach ($ not_contains [$ quote_depth ] as $ not_contains_text )
127+ {
128+ $ this ->assertNotContains ($ not_contains_text , $ text_content );
129+ }
130+ }
131+ }
132+
133+ protected function set_quote_depth ($ depth )
134+ {
135+ $ crawler = self ::request ('GET ' , 'adm/index.php?sid= ' . $ this ->sid . '&i=acp_board&mode=post ' );
136+ $ form = $ crawler ->selectButton ('Submit ' )->form ();
137+ $ values = $ form ->getValues ();
138+ $ values ['config[max_quote_depth] ' ] = $ depth ;
139+ $ form ->setValues ($ values );
140+ $ crawler = self ::submit ($ form );
141+ $ this ->assertEquals (1 , $ crawler ->filter ('.successbox ' )->count ());
142+ }
62143}
0 commit comments