@@ -76,7 +76,7 @@ class TestApiPdfSettings extends WP_UnitTestCase {
7676 */
7777 public function setUp () {
7878
79- $ this ->template_font_location = plugin_dir_path ( __FILE__ ) . 'tmp/gravityforms/fonts/ ' ;
79+ // $this->template_font_location = 'tmp/gravityforms/fonts/';
8080
8181 // $this->data = GPDFAPI::get_data_class();
8282 $ this ->class = new Api_Pdf_Settings ( GPDFAPI ::get_log_class (), GPDFAPI ::get_misc_class (), $ this ->template_font_location );
@@ -96,21 +96,35 @@ public function test_rest_api_license_endpoints() {
9696 $ this ->assertArrayHasKey ( '/gravity-pdf/v1/pdf/settings ' , $ wp_rest_server ->get_routes () );
9797 }
9898
99+
99100 /**
100101 * @since 5.2
101102 */
102- public function test_check_tmp_pdf_security () {
103-
104- /* Test unable to access directory */
105- $ response = $ this ->class -> check_tmp_pdf_security ( );
103+ public function test_create_public_tmp_directory_test_file () {
104+ /* Test able to write to directory */
105+ $ response = $ this -> class -> create_public_tmp_directory_test_file ();
106+ $ this ->assertTrue ( $ response );
106107
107- $ this ->assertSame ( 401 , $ response ->get_error_data ( 'test_public_tmp_directory_access ' )['status ' ] );
108+ /* Test unable to write to directory */
109+ // $this->assertFileExists( $this->template_font_location . $this->tmp_test_file );
108110
109- /* Test successful access on directory */
110- // $request = $this->get_request( [ 'addon_name' => 'test', 'license' => '12345' ] );
111- $ response = $ this ->class ->test_public_tmp_directory_access ();
112- $ this ->assertSame ( 200 , $ response ->get_error_data ( 'test_public_tmp_directory_access ' )['status ' ] );
113111 }
114112
113+ /**
114+ * @since 5.2
115+ */
116+ public function test_check_tmp_pdf_security ( ) {
117+
118+ $ response = $ this ->class ->check_tmp_pdf_security ();
119+
120+ /* Test unable to conver path to URL */
121+ $ this ->assertSame ( 404 , $ response ->get_error_data ( 'convert_path_to_url ' )['status ' ] );
122+
123+ /* Test unable to access generated URL */
124+ $ this ->assertSame ( 400 , $ response ->get_error_data ( 'wp_remote_get_response ' )['status ' ] );
125+
126+ // Test able to read the content of file
127+
128+ }
115129
116130}
0 commit comments