22
33namespace Tests \Feature \Api \V1 ;
44
5- use Tests \TestCase ;
6- use Illuminate \Foundation \Testing \WithFaker ;
7- use Illuminate \Foundation \Testing \RefreshDatabase ;
8- use Tests \BrowserKitTestCase ;
95use App \Models \Access \User \User ;
10-
116use App \Models \Page \Page ;
12-
137use JWTAuth ;
8+ use Tests \TestCase ;
149
1510class PageTest extends TestCase
1611{
17- public $ token ='' ;
18- public $ headers ='' ;
19- public $ user ='' ;
12+ public $ token = '' ;
13+ public $ headers = '' ;
14+ public $ user = '' ;
15+
2016 public function setUp ()
2117 {
2218 parent ::setUp ();
2319 $ this ->user = User::find (1 );
2420
2521 $ this ->token = JWTAuth::fromUser ($ this ->user );
26- $ this ->headers = ['Authorization ' => " Bearer " .$ this ->token ];
22+ $ this ->headers = ['Authorization ' => ' Bearer ' .$ this ->token ];
2723 }
24+
2825 /**
2926 * A basic test example.
3027 *
@@ -36,40 +33,40 @@ public function testExample()
3633 }
3734
3835 /**
39- * A basic test to get response form pages api
36+ * A basic test to get response form pages api.
4037 *
4138 * @return void
4239 */
40+
4341 /** @test */
4442 public function Get_records_from_pages ()
4543 {
46-
4744 $ payload = [];
48- $ response = $ this ->json ('GET ' , '/api/v1/pages ' ,$ payload , $ this ->headers );
45+ $ response = $ this ->json ('GET ' , '/api/v1/pages ' , $ payload , $ this ->headers );
4946 $ response
5047 ->assertStatus (200 )
5148 ->assertJsonStructure ([
52- 'data ' =>[
49+ 'data ' => [
5350 [
54- " id " ,
55- " title " ,
56- " status_label " ,
57- " status " ,
58- " created_at " ,
59- " created_by "
60- ]
51+ ' id ' ,
52+ ' title ' ,
53+ ' status_label ' ,
54+ ' status ' ,
55+ ' created_at ' ,
56+ ' created_by ' ,
57+ ],
6158 ],
6259 'links ' ,
63- 'meta '
60+ 'meta ' ,
6461 ]);
65-
6662 }
6763
6864 /**
69- * A basic test to get response form pages api
65+ * A basic test to get response form pages api.
7066 *
7167 * @return void
7268 */
69+
7370 /** @test */
7471 public function get_one_created_page_from_db ()
7572 {
@@ -79,101 +76,104 @@ public function get_one_created_page_from_db()
7976 $ response
8077 ->assertStatus (200 )
8178 ->assertJson ([
82- " data " => [
83- " id " => $ page ->id ,
84- " title " => $ page ->title ,
85- " status_label " => $ page ->status_label ,
86- " status " => ($ page ->isActive ()) ? 'Active ' :'InActive ' ,
87- " created_by " => $ page ->created_by ,
79+ ' data ' => [
80+ ' id ' => $ page ->id ,
81+ ' title ' => $ page ->title ,
82+ ' status_label ' => $ page ->status_label ,
83+ ' status ' => ($ page ->isActive ()) ? 'Active ' : 'InActive ' ,
84+ ' created_by ' => $ page ->created_by ,
8885 ],
8986 ]);
90-
9187 }
88+
9289 /**
9390 * Author: Indra Shastri
9491 * Date:03-03-2018
95- * A basic test to update a page from api
96- *
92+ * A basic test to update a page from api.
93+ *
9794 *
9895 * @return void
9996 */
97+
10098 /** @test */
10199 public function update_a_page_in_db_and_get_response ()
102100 {
103101 $ page = make (Page::class);
104102 $ payload = [
105- " title " => $ page ->title ,
106- " description " => $ page ->description ,
107- " cannonical_link " => $ page ->cannonical_link ,
108- " seo_title " => " some tittle " ,
109- " seo_keyword " => " some keywords " ,
110- " seo_description " => " <p> </p>↵<h1>SEO Description</h1>↵<p>some seco desctription</p>↵<p>askdsaj;ldsjfd</p> " ,
111- " status " => " 1 " ,
103+ ' title ' => $ page ->title ,
104+ ' description ' => $ page ->description ,
105+ ' cannonical_link ' => $ page ->cannonical_link ,
106+ ' seo_title ' => ' some tittle ' ,
107+ ' seo_keyword ' => ' some keywords ' ,
108+ ' seo_description ' => ' <p> </p>↵<h1>SEO Description</h1>↵<p>some seco desctription</p>↵<p>askdsaj;ldsjfd</p> ' ,
109+ ' status ' => ' 1 ' ,
112110 ];
113- $ response = "" ;
111+ $ response = '' ;
114112 $ response = $ this ->json ('PUT ' , '/api/v1/pages/1 ' , $ payload , $ this ->headers );
115-
113+
116114 $ response ->assertStatus (200 );
117115 $ response ->assertJson ([
118- " data " => [
119- " title " => $ page ->title ,
120- " status_label " => $ page ->status_label ,
121- " status " => ($ page ->isActive ()) ? 'Active ' :'InActive ' ,
122- " created_by " => "" .$ this ->user ->id ,
116+ ' data ' => [
117+ ' title ' => $ page ->title ,
118+ ' status_label ' => $ page ->status_label ,
119+ ' status ' => ($ page ->isActive ()) ? 'Active ' : 'InActive ' ,
120+ ' created_by ' => '' .$ this ->user ->id ,
123121 ],
124122 ]);
125-
126123 }
124+
127125 /**
128126 * Author: Indra Shastri
129127 * Date:03-03-2018
130- * A basic test to create a page from api
128+ * A basic test to create a page from api.
131129 *
132130 * @return void
133131 */
132+
134133 /** @test */
135134 public function create_a_new_page_in_db_and_get_response ()
136135 {
137-
138136 $ page = make (Page::class);
139137 $ payload = [
140- " title " => $ page ->title ,
141- " description " => $ page ->description ,
142- " cannonical_link " => $ page ->cannonical_link ,
143- " seo_title " => " some tittle " ,
144- " seo_keyword " => " some keywords " ,
145- " seo_description " => " <p> </p>↵<h1>SEO Description</h1>↵<p>some seco desctription</p>↵<p>askdsaj;ldsjfd</p> " ,
146- " status " => " 1 " ,
138+ ' title ' => $ page ->title ,
139+ ' description ' => $ page ->description ,
140+ ' cannonical_link ' => $ page ->cannonical_link ,
141+ ' seo_title ' => ' some tittle ' ,
142+ ' seo_keyword ' => ' some keywords ' ,
143+ ' seo_description ' => ' <p> </p>↵<h1>SEO Description</h1>↵<p>some seco desctription</p>↵<p>askdsaj;ldsjfd</p> ' ,
144+ ' status ' => ' 1 ' ,
147145 ];
148- $ response = "" ;
146+ $ response = '' ;
149147 $ response = $ this ->json ('POST ' , '/api/v1/pages ' , $ payload , $ this ->headers );
150148 $ response ->assertStatus (201 );
151149 $ response ->assertJson ([
152- " data " => [
153- " title " => $ page ->title ,
154- " status_label " => $ page ->status_label ,
155- " status " => ($ page ->isActive ()) ? 'Active ' : 'InActive ' ,
156- " created_by " => $ this ->user ->first_name ,
157- " created_at " => (\Carbon \Carbon::now ())->toDateString ()
150+ ' data ' => [
151+ ' title ' => $ page ->title ,
152+ ' status_label ' => $ page ->status_label ,
153+ ' status ' => ($ page ->isActive ()) ? 'Active ' : 'InActive ' ,
154+ ' created_by ' => $ this ->user ->first_name ,
155+ ' created_at ' => (\Carbon \Carbon::now ())->toDateString (),
158156 ],
159- ]);
160-
157+ ]);
161158 }
159+
162160 /**
163161 * Author: Indra Shastri
164162 * Date:03-03-2018
165- * A basic test to create a page from api
163+ * A basic test to create a page from api.
166164 *
167165 * @return void
168166 */
167+
169168 /** @test */
170- public function delete_page_in_db_and_get_response (){
169+ public function delete_page_in_db_and_get_response ()
170+ {
171171 $ page = create (Page::class);
172- $ payload= [];
172+ $ payload = [];
173173 $ response = $ this ->json ('DELETE ' , '/api/v1/pages/ ' .$ page ->id , $ payload , $ this ->headers );
174174 $ response ->assertStatus (200 )
175175 ->assertJson ([
176- " message " => " The Page was successfully deleted. "
177- ]);
176+ ' message ' => ' The Page was successfully deleted. ' ,
177+ ]);
178178 }
179179}
0 commit comments