',
+ ],
]);
- WP_Mock::userFunction('wp_json_encode');
+ WP_Mock::userFunction('wp_json_encode');
WP_Mock::userFunction('is_wp_error');
- WP_Mock::userFunction('wp_remote_retrieve_body');
-
+ WP_Mock::userFunction('wp_remote_retrieve_body');
// Assert that the returned result is as expected
-
- $this->assertSame( true, true );
+
+ $this->assertSame(true, true);
}
- public function testCallError() {
+ public function testCallError()
+ {
$question = 'example question';
$api_key = 'test_api_key';
$category_name = 'Test Category';
$iterator = '1';
-
+
+ WP_Mock::userFunction('add_query_arg');
+ WP_Mock::userFunction('wp_remote_get');
+ WP_Mock::userFunction('wp_remote_post');
// Simulate an error response from wp_remote_post
- WP_Mock::userFunction('wp_remote_post', [
- 'return' => new WP_Error( 'api_error', 'Something went wrong' ),
+ WP_Mock::userFunction('wp_remote_retrieve_body', [
+ 'return' => '{
+ "status": "ok",
+ "totalResults": 268,
+ "articles": [
+ {
+ "source": {
+ "id": null,
+ "name": "Hotnews.ro"
+ },
+ "author": "Mihai Bianca",
+ "title": "fanatik.ro: I se spune Maldive de Europa. Se ajunge ușor din România și e de 3 ori mai ieftină decât Grecia sau Turcia",
+ "description": "Descoperă țara din Balcani cu cea mai impetuoasă dezvoltare la nivel de turism. Este catalogată ca având plaje la fel ca în Maldive. Maldive de Europa, adică un joc frumos de cuvinte, dar și un…",
+ "url": "http://hotnews.ro/fanatik-ro-i-se-spune-maldive-de-europa-se-ajunge-usor-din-romania-si-e-de-3-ori-mai-ieftina-decat-grecia-sau-turcia-1532267",
+ "urlToImage": "https://hotnews.ro/wp-content/uploads/2024/06/Screenshot-2024-06-29-105522.png",
+ "publishedAt": "2024-06-29T07:56:14Z",
+ "content": "Descoper ara din Balcani cu cea mai impetuoas dezvoltare la nivel de turism. Este catalogat ca având plaje la fel ca în Maldive.\r\nMaldive de Europa, adic un joc frumos de cuvinte, dar i un loc pentru… [+310 chars]"
+ }
+ ]
+ }',
]);
-
- $result = AIEntries_API::call( $question, $api_key, $category_name, $iterator );
+ $result = AIEntries_API::call($question, $api_key, $category_name, $iterator);
// Verify that the result is an instance of WP_Error
- $this->assertInstanceOf( 'WP_Error', $result );
+ $this->assertInstanceOf('WP_Error', $result);
}
}
diff --git a/ai-entries/tests/classes/AIEntriesCronTest.php b/ai-entries/tests/classes/AIEntriesCronTest.php
index e822531..5574ec0 100644
--- a/ai-entries/tests/classes/AIEntriesCronTest.php
+++ b/ai-entries/tests/classes/AIEntriesCronTest.php
@@ -2,25 +2,14 @@
require_once __DIR__ . '/../../includes/class-ai-entries-cron.php';
-
class AIEntriesCronTest extends WP_Mock\Tools\TestCase
{
-
- public function test_my_six_hour_function()
+ public function test_daily_task()
{
- // Call the method to test
- $this->assertNull(AIEntries_Cron::my_six_hour_function());
- }
+ WP_Mock::userFunction('_get_cron_array');
+ $this->assertNull(AIEntries_Cron::daily_task());
- public function test_check_six_hour_function()
- {
-
- // Call the method to test
- WP_Mock::userFunction('get_transient');
- WP_Mock::userFunction('set_transient');
- $this->assertNull(AIEntries_Cron::check_six_hour_function());
}
-
public function test_show_all_cron_tasks()
{
WP_Mock::userFunction('_get_cron_array');
diff --git a/ai-entries/tests/classes/AIEntriesSettingsTest.php b/ai-entries/tests/classes/AIEntriesSettingsTest.php
index bbdbe46..1ca926e 100644
--- a/ai-entries/tests/classes/AIEntriesSettingsTest.php
+++ b/ai-entries/tests/classes/AIEntriesSettingsTest.php
@@ -48,18 +48,41 @@ public function testSettingsPageNoSubmit()
public function testSettingsPageSubmit()
{
WP_Mock::userFunction('sanitize_text_field');
- WP_Mock::userFunction('wp_json_encode');
- WP_Mock::userFunction('wp_remote_post');
- WP_Mock::userFunction('is_wp_error');
- WP_Mock::userFunction('wp_remote_retrieve_body');
+ WP_Mock::userFunction('wp_json_encode');
+ WP_Mock::userFunction('is_wp_error');
Mockery::mock('WP_Error');
WP_Mock::userFunction('get_post_permalink');
WP_Mock::userFunction('get_the_title');
WP_Mock::userFunction('_get_cron_array');
+ WP_Mock::userFunction('add_query_arg');
+ WP_Mock::userFunction('add_query_arg');
+ WP_Mock::userFunction('wp_remote_post');
+ // Simulate an error response from wp_remote_post
+ WP_Mock::userFunction('wp_remote_retrieve_body', [
+ 'return' => '{
+ "status": "ok",
+ "totalResults": 268,
+ "articles": [
+ {
+ "source": {
+ "id": null,
+ "name": "Hotnews.ro"
+ },
+ "author": "Mihai Bianca",
+ "title": "fanatik.ro: I se spune Maldive de Europa. Se ajunge ușor din România și e de 3 ori mai ieftină decât Grecia sau Turcia",
+ "description": "Descoperă țara din Balcani cu cea mai impetuoasă dezvoltare la nivel de turism. Este catalogată ca având plaje la fel ca în Maldive. Maldive de Europa, adică un joc frumos de cuvinte, dar și un…",
+ "url": "http://hotnews.ro/fanatik-ro-i-se-spune-maldive-de-europa-se-ajunge-usor-din-romania-si-e-de-3-ori-mai-ieftina-decat-grecia-sau-turcia-1532267",
+ "urlToImage": "https://hotnews.ro/wp-content/uploads/2024/06/Screenshot-2024-06-29-105522.png",
+ "publishedAt": "2024-06-29T07:56:14Z",
+ "content": "Descoper ara din Balcani cu cea mai impetuoas dezvoltare la nivel de turism. Este catalogat ca având plaje la fel ca în Maldive.\r\nMaldive de Europa, adic un joc frumos de cuvinte, dar i un loc pentru… [+310 chars]"
+ }
+ ]
+ }',
+ ]);
// Mock POST request with submit
$_POST = [
'submit' => true,
- 'aic_entries_nonce' => 'fake_nonce',
+ 'aic_entries_nonce' => 'fake_nonce',
'question' => 'test question',
'num_calls' => 1,
'api_key' => 'test_api_key',
diff --git a/readme.md b/readme.md
index efbc799..64f08db 100644
--- a/readme.md
+++ b/readme.md
@@ -1,17 +1,55 @@
# AIEntries Plugin
-This plugin uses Google artificial intelligence (GEMINI) and stability.AI to automate the creation of standard WordPress posts based on configurable parameters from the WordPress admin view.
+This plugin uses Google artificial intelligence (GEMINI) and stability.AI to automate the creation of standard WordPress posts based on configurable parameters from the WordPress admin view. It can create posts from any topic you configure from the administrator view. To ensure quality content, this tool is integrated with several free-to-use APIs to fulfill its functionality.
+
+## This plugin is aware of Google's advice on AI content:
+https://developers.google.com/search/blog/2023/02/google-search-and-ai-content?hl=es-419
+
+In order to follow they guidelines we are doing these processes:
+
+### News API:
+
+we use this api to get real articles
+
+https://newsapi.org/docs
+
+### Google Gemini API:
+
+We use this api to generate original content based in real one
+
+https://ai.google.dev/gemini-api?hl=es-419
+
+### Stability AI:
+
+We use this api to generate post's featured imaged based on ai generated article's title .
+
+https://stability.ai/
+
+
+### DISCLAIMER : THIS IS AN IN PROGRESS PROJECT .
+
+
+
+
+
+
+
+
+
+
-
-
# Getting started! 💥 🚀
## Requirements ✅
+You need to have a NEWS API's API KEY to use this plugin.
+
+You can get one for free here : https://newsapi.org/docs
+
You need to have a GEMINI API KEY to use this plugin.
You can get one for free here : https://ai.google.dev/gemini-api/docs/api-key