Skip to content

Commit 4f50aec

Browse files
Style issues.
1 parent ddeee53 commit 4f50aec

3 files changed

Lines changed: 134 additions & 134 deletions

File tree

src/class-tiny-compress-client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function create_key($email, $options) {
128128
try {
129129
$this->last_error_code = 0;
130130
$this->set_request_options(
131-
\Tinify\Tinify::getClient(\Tinify\Tinify::ANONYMOUS)
131+
\Tinify\Tinify::getClient( \Tinify\Tinify::ANONYMOUS )
132132
);
133133

134134
\Tinify\createKey( $email, $options );

src/views/account-status-connected.php

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,60 @@
11
<div class="tiny-account-status" id="tiny-account-status" data-state="complete">
22
<div class="status <?php echo $status->ok ? ( $status->pending ? 'status-pending' : 'status-success' ) : 'status-failure'; ?>">
33
<p class="status"><?php
4-
if ( $status->ok ) {
5-
if ( isset( $status->message ) ) {
6-
echo esc_html__( $status->message, 'tiny-compress-images' );
7-
} else {
8-
echo esc_html__( 'Your account is connected', 'tiny-compress-images' );
9-
}
4+
if ( $status->ok ) {
5+
if ( isset( $status->message ) ) {
6+
echo esc_html__( $status->message, 'tiny-compress-images' );
107
} else {
11-
echo esc_html__( 'Connection unsuccessful', 'tiny-compress-images' );
8+
echo esc_html__( 'Your account is connected', 'tiny-compress-images' );
129
}
10+
} else {
11+
echo esc_html__( 'Connection unsuccessful', 'tiny-compress-images' );
12+
}
1313
?></p>
1414
<p><?php
15-
if ( $status->ok ) {
16-
$compressions = self::get_compression_count();
17-
/* It is not possible to check if a subscription is free or flexible. */
18-
if ( $compressions == Tiny_Config::MONTHLY_FREE_COMPRESSIONS ) {
19-
$link = '<a href="https://tinypng.com/developers" target="_blank">' . esc_html__( 'TinyPNG API account', 'tiny-compress-images' ) . '</a>';
20-
printf( esc_html__(
21-
'You have reached your limit of %s compressions this month.',
22-
'tiny-compress-images'
23-
), $compressions );
24-
echo '<br>';
25-
printf( esc_html__(
26-
'If you need to compress more images you can change your %s.',
27-
'tiny-compress-images'
28-
), $link );
29-
} else {
30-
printf( esc_html__(
31-
'You have made %s compressions this month.',
32-
'tiny-compress-images'
33-
), $compressions );
34-
}
15+
if ( $status->ok ) {
16+
$compressions = self::get_compression_count();
17+
/* It is not possible to check if a subscription is free or flexible. */
18+
if ( $compressions == Tiny_Config::MONTHLY_FREE_COMPRESSIONS ) {
19+
$link = '<a href="https://tinypng.com/developers" target="_blank">' . esc_html__( 'TinyPNG API account', 'tiny-compress-images' ) . '</a>';
20+
printf( esc_html__(
21+
'You have reached your limit of %s compressions this month.',
22+
'tiny-compress-images'
23+
), $compressions );
24+
echo '<br>';
25+
printf( esc_html__(
26+
'If you need to compress more images you can change your %s.',
27+
'tiny-compress-images'
28+
), $link );
3529
} else {
36-
if ( isset( $status->message ) ) {
37-
echo esc_html__( 'Error', 'tiny-compress-images' ) . ': ';
38-
echo esc_html__( $status->message, 'tiny-compress-images' );
39-
} else {
40-
esc_html__(
41-
'API status could not be checked, enable cURL for more information',
42-
'tiny-compress-images'
43-
);
44-
}
45-
}
46-
?></p>
47-
<p><?php
48-
if ( defined( 'TINY_API_KEY' ) ) {
49-
echo sprintf( esc_html__(
50-
'The API key has been configured in %s',
30+
printf( esc_html__(
31+
'You have made %s compressions this month.',
5132
'tiny-compress-images'
52-
), 'wp-config.php' );
33+
), $compressions );
34+
}
35+
} else {
36+
if ( isset( $status->message ) ) {
37+
echo esc_html__( 'Error', 'tiny-compress-images' ) . ': ';
38+
echo esc_html__( $status->message, 'tiny-compress-images' );
5339
} else {
54-
echo '<a href="#" onclick="jQuery(\'div.tiny-account-status div.update\').toggle(); jQuery(\'div.tiny-account-status div.status\').toggle(); return false">';
55-
echo esc_html__( 'Change API key', 'tiny-compress-images' );
56-
echo '</a>';
40+
esc_html__(
41+
'API status could not be checked, enable cURL for more information',
42+
'tiny-compress-images'
43+
);
5744
}
45+
}
46+
?></p>
47+
<p><?php
48+
if ( defined( 'TINY_API_KEY' ) ) {
49+
echo sprintf( esc_html__(
50+
'The API key has been configured in %s',
51+
'tiny-compress-images'
52+
), 'wp-config.php' );
53+
} else {
54+
echo '<a href="#" onclick="jQuery(\'div.tiny-account-status div.update\').toggle(); jQuery(\'div.tiny-account-status div.status\').toggle(); return false">';
55+
echo esc_html__( 'Change API key', 'tiny-compress-images' );
56+
echo '</a>';
57+
}
5858
?></p>
5959
</div>
6060

test/integration/SettingsIntegrationTest.php

Lines changed: 87 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -78,91 +78,91 @@ public function test_settings_should_persist_all_disabled_sizes() {
7878
$this->assertEquals( 0, count( $enabled_sizes ) );
7979
}
8080

81-
// public function test_api_key_input_presence() {
82-
// $elements = self::$driver->findElements( WebDriverBy::name( 'tinypng_api_key' ) );
83-
// $this->assertEquals( 1, count( $elements ) );
84-
// }
85-
86-
// public function test_should_show_total_images_info() {
87-
// $this->enable_compression_sizes( array( '0', 'thumbnail', 'medium', 'large') );
88-
// $element = self::$driver->findElement( WebDriverBy::id( 'tiny-image-sizes-notice' ) );
89-
// $this->assertContains( 'With these settings you can compress at least 125 images for free each month.', $element->getText() );
90-
// }
91-
//
92-
// public function test_should_update_total_images_info() {
93-
// $this->enable_compression_sizes( array( '0', 'thumbnail', 'medium', 'large') );
94-
// $element = self::$driver->findElement(
95-
// WebDriverBy::xpath( '//input[@type="checkbox" and @name="tinypng_sizes[0]" and @checked="checked"]' ));
96-
// $element->click();
97-
// self::$driver->wait( 2 )->until(WebDriverExpectedCondition::textToBePresentInElement(
98-
// WebDriverBy::cssSelector( '#tiny-image-sizes-notice' ),
99-
// 'With these settings you can compress at least 166 images for free each month.'));
100-
// }
101-
//
102-
// public function test_should_show_correct_no_image_sizes_info() {
103-
// $elements = self::$driver->findElements(
104-
// WebDriverBy::xpath( '//input[@type="checkbox" and starts-with(@name, "tinypng_sizes") and @checked="checked"]' ));
105-
// foreach ( $elements as $element ) {
106-
// $element->click();
107-
// }
108-
// self::$driver->wait( 2 )->until(WebDriverExpectedCondition::textToBePresentInElement(
109-
// WebDriverBy::cssSelector( '#tiny-image-sizes-notice' ), 'With these settings no images will be compressed.'));
110-
// // Not really necessary anymore to assert this.
111-
// $elements = self::$driver->findElement( WebDriverBy::id( 'tiny-image-sizes-notice' ) )->findElements( WebDriverBy::tagName( 'p' ) );
112-
// $statuses = array_map( 'innerText', $elements );
113-
// $this->assertContains( 'With these settings no images will be compressed.', $statuses );
114-
// }
115-
//
116-
// public function test_should_show_resizing_when_original_enabled() {
117-
// $element = self::$driver->findElement( WebDriverBy::id( 'tinypng_sizes_0' ) );
118-
// if ( ! $element->getAttribute( 'checked' ) ) {
119-
// $element->click();
120-
// }
121-
// $labels = self::$driver->findElements( WebDriverBy::tagName( 'label' ) );
122-
// $texts = array_map( 'innerText', $labels );
123-
// $this->assertContains( 'Resize and compress the original image', $texts );
124-
// $paragraphs = self::$driver->findElements( WebDriverBy::tagName( 'p' ) );
125-
// $texts = array_map( 'innerText', $paragraphs );
126-
// $this->assertNotContains( 'Enable compression of the original image size for more options.', $texts );
127-
// }
128-
//
129-
// public function test_should_not_show_resizing_when_original_disabled() {
130-
// $element = self::$driver->findElement( WebDriverBy::id( 'tinypng_sizes_0' ) );
131-
// if ( $element->getAttribute( 'checked' ) ) {
132-
// $element->click();
133-
// }
134-
// self::$driver->wait( 1 )->until(WebDriverExpectedCondition::textToBePresentInElement(
135-
// WebDriverBy::cssSelector( 'p.tiny-resize-unavailable' ), 'Enable compression of the original image size for more options.'));
136-
// $labels = self::$driver->findElements( WebDriverBy::tagName( 'label' ) );
137-
// $texts = array_map( 'innerText', $labels );
138-
// $this->assertNotContains( 'Resize and compress orginal images to fit within:', $texts );
139-
// }
140-
//
141-
// public function test_should_not_show_resizing_when_original_disabled_when_shown_first() {
142-
// $this->enable_compression_sizes( array( 'original') );
143-
// self::$driver->navigate()->refresh();
144-
// $this->assertEquals('Enable compression of the original image size for more options.',
145-
// self::$driver->findElement( WebDriverBy::cssSelector( '.tiny-resize-unavailable' ) )->getText());
146-
// }
147-
//
148-
// public function test_should_persist_resizing_settings() {
149-
// $this->enable_resize( 123, 456 );
150-
// $this->assertEquals( '123', self::$driver->findElement( WebDriverBy::id( 'tinypng_resize_original_width' ) )->getAttribute( 'value' ) );
151-
// $this->assertEquals( '456', self::$driver->findElement( WebDriverBy::id( 'tinypng_resize_original_height' ) )->getAttribute( 'value' ) );
152-
// }
153-
//
154-
// public function test_status_presence_ok() {
155-
// reset_webservice();
156-
// $this->set_api_key( 'PNG123' );
157-
// self::$driver->wait( 2 )->until(WebDriverExpectedCondition::textToBePresentInElement(
158-
// WebDriverBy::cssSelector( '#tiny-compress-status p.tiny-account-status' ),
159-
// 'Your account is connected'));
160-
// }
161-
//
162-
// public function test_status_presense_fail() {
163-
// $this->set_api_key( 'INVALID123', false );
164-
// self::$driver->wait( 2 )->until(WebDriverExpectedCondition::textToBePresentInElement(
165-
// WebDriverBy::cssSelector( '#tiny-compress-status p.tiny-update-account-message' ),
166-
// 'The key that you have entered is not valid'));
167-
// }
81+
// public function test_api_key_input_presence() {
82+
// $elements = self::$driver->findElements( WebDriverBy::name( 'tinypng_api_key' ) );
83+
// $this->assertEquals( 1, count( $elements ) );
84+
// }
85+
86+
// public function test_should_show_total_images_info() {
87+
// $this->enable_compression_sizes( array( '0', 'thumbnail', 'medium', 'large') );
88+
// $element = self::$driver->findElement( WebDriverBy::id( 'tiny-image-sizes-notice' ) );
89+
// $this->assertContains( 'With these settings you can compress at least 125 images for free each month.', $element->getText() );
90+
// }
91+
//
92+
// public function test_should_update_total_images_info() {
93+
// $this->enable_compression_sizes( array( '0', 'thumbnail', 'medium', 'large') );
94+
// $element = self::$driver->findElement(
95+
// WebDriverBy::xpath( '//input[@type="checkbox" and @name="tinypng_sizes[0]" and @checked="checked"]' ));
96+
// $element->click();
97+
// self::$driver->wait( 2 )->until(WebDriverExpectedCondition::textToBePresentInElement(
98+
// WebDriverBy::cssSelector( '#tiny-image-sizes-notice' ),
99+
// 'With these settings you can compress at least 166 images for free each month.'));
100+
// }
101+
//
102+
// public function test_should_show_correct_no_image_sizes_info() {
103+
// $elements = self::$driver->findElements(
104+
// WebDriverBy::xpath( '//input[@type="checkbox" and starts-with(@name, "tinypng_sizes") and @checked="checked"]' ));
105+
// foreach ( $elements as $element ) {
106+
// $element->click();
107+
// }
108+
// self::$driver->wait( 2 )->until(WebDriverExpectedCondition::textToBePresentInElement(
109+
// WebDriverBy::cssSelector( '#tiny-image-sizes-notice' ), 'With these settings no images will be compressed.'));
110+
// // Not really necessary anymore to assert this.
111+
// $elements = self::$driver->findElement( WebDriverBy::id( 'tiny-image-sizes-notice' ) )->findElements( WebDriverBy::tagName( 'p' ) );
112+
// $statuses = array_map( 'innerText', $elements );
113+
// $this->assertContains( 'With these settings no images will be compressed.', $statuses );
114+
// }
115+
//
116+
// public function test_should_show_resizing_when_original_enabled() {
117+
// $element = self::$driver->findElement( WebDriverBy::id( 'tinypng_sizes_0' ) );
118+
// if ( ! $element->getAttribute( 'checked' ) ) {
119+
// $element->click();
120+
// }
121+
// $labels = self::$driver->findElements( WebDriverBy::tagName( 'label' ) );
122+
// $texts = array_map( 'innerText', $labels );
123+
// $this->assertContains( 'Resize and compress the original image', $texts );
124+
// $paragraphs = self::$driver->findElements( WebDriverBy::tagName( 'p' ) );
125+
// $texts = array_map( 'innerText', $paragraphs );
126+
// $this->assertNotContains( 'Enable compression of the original image size for more options.', $texts );
127+
// }
128+
//
129+
// public function test_should_not_show_resizing_when_original_disabled() {
130+
// $element = self::$driver->findElement( WebDriverBy::id( 'tinypng_sizes_0' ) );
131+
// if ( $element->getAttribute( 'checked' ) ) {
132+
// $element->click();
133+
// }
134+
// self::$driver->wait( 1 )->until(WebDriverExpectedCondition::textToBePresentInElement(
135+
// WebDriverBy::cssSelector( 'p.tiny-resize-unavailable' ), 'Enable compression of the original image size for more options.'));
136+
// $labels = self::$driver->findElements( WebDriverBy::tagName( 'label' ) );
137+
// $texts = array_map( 'innerText', $labels );
138+
// $this->assertNotContains( 'Resize and compress orginal images to fit within:', $texts );
139+
// }
140+
//
141+
// public function test_should_not_show_resizing_when_original_disabled_when_shown_first() {
142+
// $this->enable_compression_sizes( array( 'original') );
143+
// self::$driver->navigate()->refresh();
144+
// $this->assertEquals('Enable compression of the original image size for more options.',
145+
// self::$driver->findElement( WebDriverBy::cssSelector( '.tiny-resize-unavailable' ) )->getText());
146+
// }
147+
//
148+
// public function test_should_persist_resizing_settings() {
149+
// $this->enable_resize( 123, 456 );
150+
// $this->assertEquals( '123', self::$driver->findElement( WebDriverBy::id( 'tinypng_resize_original_width' ) )->getAttribute( 'value' ) );
151+
// $this->assertEquals( '456', self::$driver->findElement( WebDriverBy::id( 'tinypng_resize_original_height' ) )->getAttribute( 'value' ) );
152+
// }
153+
//
154+
// public function test_status_presence_ok() {
155+
// reset_webservice();
156+
// $this->set_api_key( 'PNG123' );
157+
// self::$driver->wait( 2 )->until(WebDriverExpectedCondition::textToBePresentInElement(
158+
// WebDriverBy::cssSelector( '#tiny-compress-status p.tiny-account-status' ),
159+
// 'Your account is connected'));
160+
// }
161+
//
162+
// public function test_status_presense_fail() {
163+
// $this->set_api_key( 'INVALID123', false );
164+
// self::$driver->wait( 2 )->until(WebDriverExpectedCondition::textToBePresentInElement(
165+
// WebDriverBy::cssSelector( '#tiny-compress-status p.tiny-update-account-message' ),
166+
// 'The key that you have entered is not valid'));
167+
// }
168168
}

0 commit comments

Comments
 (0)