diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-05-28 21:45:39 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-05-28 21:45:39 +0200 |
commit | e2308df14d61c91ab93a6da191b7df6f83ee5af8 (patch) | |
tree | 31da598c3aaf7012a30a43ada5131e2a83f7b4c8 /tests/content_visibility | |
parent | c8e7b2c5d4a8bbc33cc9cf394fa2a4f978cca63c (diff) | |
parent | ad4a373557adc93c0490471b472312483ac0b1a0 (diff) | |
download | forums-e2308df14d61c91ab93a6da191b7df6f83ee5af8.tar forums-e2308df14d61c91ab93a6da191b7df6f83ee5af8.tar.gz forums-e2308df14d61c91ab93a6da191b7df6f83ee5af8.tar.bz2 forums-e2308df14d61c91ab93a6da191b7df6f83ee5af8.tar.xz forums-e2308df14d61c91ab93a6da191b7df6f83ee5af8.zip |
Merge pull request #2426 from Nicofuma/ticket/12174
[ticket/12174] Update topic_attachment flag when a post is soft-deleted
* Nicofuma/ticket/12174:
[ticket/12174] Add tests
[ticket/12174] Coding style
[ticket/12174] Remove $update_topic_attachments_flag
[ticket/12174] Don't update the flag for a post without attachment
[ticket/12174] Update the conditions
[ticket/12174] Remove inline assignment
[ticket/12174] Update sql query
[ticket/12174] Revert the changes on $topic_update_array
[ticket/12174] Corrections
[ticket/12174] Update topic_attachment flag when a post is soft-deleted
Diffstat (limited to 'tests/content_visibility')
-rw-r--r-- | tests/content_visibility/fixtures/set_post_visibility.xml | 84 | ||||
-rw-r--r-- | tests/content_visibility/set_post_visibility_test.php | 41 |
2 files changed, 125 insertions, 0 deletions
diff --git a/tests/content_visibility/fixtures/set_post_visibility.xml b/tests/content_visibility/fixtures/set_post_visibility.xml index 5f792d0f05..1b8dac2670 100644 --- a/tests/content_visibility/fixtures/set_post_visibility.xml +++ b/tests/content_visibility/fixtures/set_post_visibility.xml @@ -10,6 +10,7 @@ <column>topic_posts_approved</column> <column>topic_posts_softdeleted</column> <column>topic_posts_unapproved</column> + <column>topic_attachment</column> <row> <value>1</value> <value>1</value> @@ -20,6 +21,7 @@ <value>1</value> <value>1</value> <value>1</value> + <value>0</value> </row> <row> @@ -32,6 +34,7 @@ <value>1</value> <value>1</value> <value>1</value> + <value>0</value> </row> <row> @@ -44,6 +47,33 @@ <value>1</value> <value>0</value> <value>0</value> + <value>0</value> + </row> + + <row> + <value>10</value> + <value>10</value> + <value>1</value> + <value>Only 3 posts (2 with attachments)</value> + <value>10</value> + <value>12</value> + <value>3</value> + <value>0</value> + <value>0</value> + <value>1</value> + </row> + + <row> + <value>11</value> + <value>10</value> + <value>1</value> + <value>Only 2 posts (1 with attachments)</value> + <value>13</value> + <value>14</value> + <value>3</value> + <value>0</value> + <value>0</value> + <value>1</value> </row> </table> <table name="phpbb_posts"> @@ -53,6 +83,7 @@ <column>forum_id</column> <column>post_visibility</column> <column>post_text</column> + <column>post_attachment</column> <row> <value>1</value> <value>1</value> @@ -60,6 +91,7 @@ <value>1</value> <value>0</value> <value>Unapproved</value> + <value>0</value> </row> <row> <value>2</value> @@ -68,6 +100,7 @@ <value>1</value> <value>1</value> <value>Approved</value> + <value>0</value> </row> <row> <value>3</value> @@ -76,6 +109,7 @@ <value>1</value> <value>2</value> <value>Softdeleted</value> + <value>0</value> </row> <row> @@ -85,6 +119,7 @@ <value>1</value> <value>0</value> <value>Unapproved</value> + <value>0</value> </row> <row> <value>5</value> @@ -93,6 +128,7 @@ <value>1</value> <value>1</value> <value>Approved</value> + <value>0</value> </row> <row> <value>6</value> @@ -101,6 +137,7 @@ <value>1</value> <value>1</value> <value>Approved 2</value> + <value>0</value> </row> <row> <value>7</value> @@ -109,6 +146,7 @@ <value>1</value> <value>2</value> <value>Softdeleted</value> + <value>0</value> </row> <row> <value>8</value> @@ -117,6 +155,52 @@ <value>1</value> <value>1</value> <value>Approved</value> + <value>0</value> + </row> + <row> + <value>10</value> + <value>1</value> + <value>10</value> + <value>10</value> + <value>1</value> + <value>Softdeleted</value> + <value>1</value> + </row> + <row> + <value>11</value> + <value>1</value> + <value>10</value> + <value>10</value> + <value>1</value> + <value>Softdeleted</value> + <value>1</value> + </row> + <row> + <value>12</value> + <value>1</value> + <value>10</value> + <value>10</value> + <value>1</value> + <value>Approved</value> + <value>0</value> + </row> + <row> + <value>13</value> + <value>1</value> + <value>11</value> + <value>10</value> + <value>1</value> + <value>Approved</value> + <value>1</value> + </row> + <row> + <value>14</value> + <value>1</value> + <value>11</value> + <value>10</value> + <value>1</value> + <value>Approved</value> + <value>0</value> </row> </table> <table name="phpbb_users"> diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php index bdff1c0a85..abfefaddfa 100644 --- a/tests/content_visibility/set_post_visibility_test.php +++ b/tests/content_visibility/set_post_visibility_test.php @@ -144,4 +144,45 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t $this->assertEquals($expected_topic, $db->sql_fetchrowset($result)); $db->sql_freeresult($result); } + + public function set_post_soft_deleted_data() + { + return array( + array( + 10, 10, 10, + 1, time(), 'soft-deleted', + true, false, + array(array('topic_attachment' => 1)), + ), + array( + 13, 11, 10, + 1, time(), 'soft-deleted', + true, false, + array(array('topic_attachment' => 0)), + ), + ); + } + + /** + * @dataProvider set_post_soft_deleted_data + */ + public function test_set_post_soft_deleted($post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest, $expected) + { + global $cache, $db, $auth, $phpbb_root_path, $phpEx; + + $cache = new phpbb_mock_cache; + $db = $this->new_dbal(); + $auth = $this->getMock('\phpbb\auth\auth'); + $user = $this->getMock('\phpbb\user'); + $content_visibility = new \phpbb\content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + + $content_visibility->set_post_visibility(ITEM_DELETED, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest); + + $result = $db->sql_query('SELECT topic_attachment + FROM phpbb_topics + WHERE topic_id = ' . $topic_id); + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + $db->sql_freeresult($result); + } } |