PluginProbe
Vimeography: Vimeo Video Gallery WordPress Plugin / 2.2
Vimeography: Vimeo Video Gallery WordPress Plugin v2.2
2.4.9 2.4.8 trunk 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.5.7 0.6 0.6.1 0.6.2 0.6.3 0.6.4 0.6.5 0.6.6 0.6.7 0.6.8 0.6.8.1 0.6.9 0.6.9.1 0.6.9.2 0.7 0.8 All 103 releases
vimeography / tests / unit-tests / test-update.php

test-update.php in Vimeography: Vimeo Video Gallery WordPress Plugin 2.2, at tests/unit-tests/test-update.php

174 lines 6.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Vimeography_Unit_Tests;
4
5 class Tests_Update extends Vimeography_UnitTestCase {
6
7 protected $_class;
8 protected $_addons;
9
10 protected $_fixture_activation_keys = array();
11
12 /**
13 * Runs before every test.
14 * Think of it as emulating what would usually happen once the plugin is activated on a Wordpress site.
15 */
16 public function setUp() {
17 parent::setUp();
18 $this->_class = new \Vimeography_Update;
19 $this->_addons = \Vimeography::get_instance()->addons;
20
21 $entry = new \stdClass();
22 $entry->activation_key = 'ABCDEFED12345678';
23 $entry->product_name = 'Journey';
24 $entry->plugin_name = 'vimeography-journey';
25
26 $this->_fixture_activation_keys[] = $entry;
27
28 $bugsauce = array(
29 'name' => 'Bugsauce',
30 'theme-uri' => 'vimeography.com/themes/bugsauce',
31 'version' => '1.0.2',
32 'description' => 'cool theme.',
33 'author' => 'Dave Kiss',
34 'author-uri' => 'http://davekiss.com',
35 'basename' => 'vimeography-bugsauce/vimeography-bugsauce.php',
36 'slug' => 'vimeography-bugsauce',
37 'thumbnail' => 'path/to/thumbnail.jpg',
38 'file_path' => realpath( dirname( __FILE__ ) . '/../fixtures/vimeography-journey/vimeography-journey.php' ),
39 'plugin_path' => realpath( dirname( __FILE__ ) . '/../fixtures/vimeography-journey/' ),
40 'type' => 'theme',
41 'partials_path' => 'path/to/partials',
42 'settings_file' => realpath( dirname( __FILE__ ) . '/../fixtures/vimeography-journey/settings.php' ),
43 );
44
45 $journey = array(
46 'name' => 'Journey',
47 'theme-uri' => 'vimeography.com/themes/journey',
48 'version' => '1.0.5',
49 'description' => 'cool theme.',
50 'author' => 'Dave Kiss',
51 'author-uri' => 'http://davekiss.com',
52 'basename' => 'vimeography-journey/vimeography-journey.php',
53 'slug' => 'vimeography-journey',
54 'thumbnail' => 'path/to/thumbnail.jpg',
55 'file_path' => realpath( dirname( __FILE__ ) . '/../fixtures/vimeography-journey/vimeography-journey.php' ),
56 'plugin_path' => realpath( dirname( __FILE__ ) . '/../fixtures/vimeography-journey/' ),
57 'type' => 'theme',
58 'partials_path' => 'path/to/partials',
59 'settings_file' => realpath( dirname( __FILE__ ) . '/../fixtures/vimeography-journey/settings.php' ),
60 );
61
62 $this->_addons->themes[0] = $bugsauce;
63 $this->_addons->themes[] = $journey;
64 $this->_addons->installed_addons[0] = $bugsauce;
65 $this->_addons->installed_addons[] = $journey;
66 }
67
68 /**
69 * @covers Vimeography_Update::_endpoint
70 */
71 public function test_endpoint_uri_is_correct() {
72 $endpoint = new \ReflectionProperty(
73 'Vimeography_Update',
74 '_endpoint'
75 );
76
77 $endpoint->setAccessible( true );
78 $val = $endpoint->getValue($this->_class);
79
80 $this->assertEquals( 'https://vimeography.com', $val);
81 }
82
83 /**
84 * @covers Vimeography_Update::_includes()
85 */
86 public function test_edd_plugin_updater_included() {
87 $this->assertTrue( class_exists('EDD_SL_Plugin_Updater') );
88 }
89
90 /**
91 * @covers Vimeography_Update::_hooks()
92 */
93 public function test_plugins_page_hook_was_added() {
94 $this->assertGreaterThan(0, has_action('load-plugins.php', array($this->_class, 'vimeography_check_for_missing_activation_keys') ) );
95 }
96
97 /**
98 * @covers Vimeography_Update::vimeography_is_addon_missing_activation_key()
99 */
100 public function test_if_missing_plugin_activation_key_returns_true() {
101 $bugsauce = $this->_addons->themes[0];
102 $updater = $this->_class->vimeography_set_activation_keys($this->_fixture_activation_keys);
103 $result = $this->_class->vimeography_is_addon_missing_activation_key($bugsauce);
104 $this->assertTrue( $result );
105 }
106
107 /**
108 * @covers Vimeography_Update::vimeography_is_addon_missing_activation_key()
109 */
110 public function test_if_found_plugin_activation_key_returns_false() {
111 $journey = $this->_addons->themes[1];
112 $updater = $this->_class->vimeography_set_activation_keys($this->_fixture_activation_keys);
113 $result = $updater->vimeography_is_addon_missing_activation_key($journey);
114 $this->assertFalse( $result );
115 }
116
117 /**
118 * @covers Vimeography_Update::vimeography_check_for_missing_activation_keys()
119 */
120 public function test_addon_license_message_hook_added_to_plugin_row_for_addons_with_missing_licenses() {
121 $this->_class->vimeography_check_for_missing_activation_keys();
122 $this->assertGreaterThan(0, has_action('after_plugin_row_vimeography-journey/vimeography-journey.php', array($this->_class, 'vimeography_addon_update_message') ) );
123 }
124
125 /**
126 * @covers Vimeography_Update::vimeography_check_for_missing_activation_keys()
127 */
128 public function test_addon_license_message_hook_skipped_for_addons_with_licenses() {
129 $updater = $this->_class->vimeography_set_activation_keys($this->_fixture_activation_keys);
130 $this->_class->vimeography_check_for_missing_activation_keys();
131 $this->assertFalse(has_action('after_plugin_row_vimeography-journey/vimeography-journey.php', array($this->_class, 'vimeography_addon_update_message') ) );
132 }
133
134 /**
135 * @covers Vimeography_Update::vimeography_check_if_activation_key_exists()
136 */
137 public function test_duplicate_activation_key_returns_true() {
138 $updater = $this->_class->vimeography_set_activation_keys($this->_fixture_activation_keys);
139 $result = $updater->vimeography_check_if_activation_key_exists('ABCDEFED12345678');
140 $this->assertTrue( $result );
141 }
142
143 /**
144 * @covers Vimeography_Update::vimeography_check_if_activation_key_exists()
145 */
146 public function test_unique_activation_key_returns_false() {
147 $result = $this->_class->vimeography_check_if_activation_key_exists('ABCDEFED12345678');
148 $this->assertFalse( $result );
149 }
150
151 /**
152 * @covers Vimeography_Update::_vimeography_remove_activation_key()
153 */
154
155 public function test_remove_activation_key() {
156 $this->_class->vimeography_set_activation_keys($this->_fixture_activation_keys);
157
158 // Get a handle to the protected method
159 $remove_key = new \ReflectionMethod(
160 'Vimeography_Update',
161 '_vimeography_remove_activation_key'
162 );
163
164 $remove_key->setAccessible( true );
165 $actual = $remove_key->invoke( $this->_class, 'ABCDEFED12345678' );
166 $this->assertTrue( $actual );
167 }
168
169 public function tearDown() {
170 delete_site_option('vimeography_activation_keys');
171 }
172
173 }
174