diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 51c113b..665c510 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -4,38 +4,38 @@ on:
branches: [master]
paths-ignore:
- "**.md"
- - ".github/workflows/**"
+
pull_request:
branches: [master]
paths-ignore:
- "**.md"
- - ".github/workflows/**"
jobs:
build-test:
runs-on: ubuntu-latest
strategy:
matrix:
- php: [7.2, 7.3, 7.4, 8.0]
+ php: [7.3, 7.4, 8.0]
steps:
- uses: actions/checkout@v1
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
+ coverage: xdebug2
- uses: php-actions/composer@v5
- - name: phpunit
- uses: php-actions/phpunit@v2
+ - name: Run phpunit
+ run: vendor/bin/phpunit --coverage-clover="coverage.xml"
- - name: codecov test
+
+ - name: Run codecov
uses: codecov/codecov-action@v1
with:
- ref: ${{ github.head_ref }}
- token: ${{ secrets.CODECOV_TOKEN }}
- verbose: true
-
-
-
-
-
\ No newline at end of file
+ token: ${{ secrets.CODECOV_TOKEN }}
+ flags: unittests
+ name: codecov-umbrella
+ fail_ci_if_error: false
+ verbose: true
+
+
diff --git a/.gitignore b/.gitignore
index a2dfdd7..d9738e0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
/.idea
composer.lock
.phpunit.result.cache
+coverage.xml
\ No newline at end of file
diff --git a/phpunit.xml b/phpunit.xml
index d246ac6..97e5532 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -1,40 +1,17 @@
-
-
-
-
- src
-
-
-
- src
- ./test/AbstractTesting.php
- ./test/DummyCredentials.php
- ./test/Model/ObjectUsedByTrait.php
- ./test/Client/TempObject.php
-
-
-
-
-
- ./test/
- ./test/AbstractTesting.php
- ./test/DummyCredentials.php
- ./test/Model/ObjectUsedByTrait.php
- ./test/Client/TempObject.php
+
+ ./test
-
+
+
+ ./src
+
+
+
\ No newline at end of file
diff --git a/src/Command/ClientTest.php b/src/Command/ClientTest.php
deleted file mode 100644
index 3e3caf1..0000000
--- a/src/Command/ClientTest.php
+++ /dev/null
@@ -1,49 +0,0 @@
- 'https://moceanapi.com',
- 'mocean-command' => McBuilder::create()
- ->add(
- Mc::tgSendText()
- ->setFrom("bot_username")
- ->setTo("123456789")
- ->setContent("Hello world")
- ),
- 'mocean-resp-format' => 'json'
- ];
-
- $mockHttp = $this->makeMockHttpClient(function (RequestInterface $request) use ($inputParams) {
- $this->assertEquals('POST', $request->getMethod());
- $this->assertEquals($this->getTestUri('/send-message'), $request->getUri()->getPath());
- $body = $this->getContentFromRequest($request);
- $this->assertEquals($inputParams['mocean-event-url'], $body['mocean-event-url']);
- $this->assertEquals(
- Mc::tgSendText()
- ->setFrom("bot_username")
- ->setTo("123456789")
- ->setContent("Hello world")
- ->getRequestData(),
-
- json_decode($body['mocean-command'], true)[0]
- );
-
- return $this->getResponse('command.xml');
- });
-
- $client = $this->makeMoceanClientWithMockHttpClient($mockHttp);
-
- $commandRes = $client->command()->execute($inputParams);
- $this->assertInstanceOf(\Mocean\Command\Commander::class, $commandRes);
- }
-}
\ No newline at end of file
diff --git a/src/Command/CommanderTest.php b/src/Command/CommanderTest.php
deleted file mode 100644
index ad83934..0000000
--- a/src/Command/CommanderTest.php
+++ /dev/null
@@ -1,27 +0,0 @@
- 'testing event url',
- 'mocean-command' => '"testing mocean command"',
- 'mocean-resp-format' => 'json',
- ];
-
-
- $setterReq = new Commander();
- $setterReq->setEventUrl('testing event url');
- $setterReq->setCommand('testing mocean command');
- $setterReq->setResponseFormat('json');
-
- $this->assertEquals($params, $setterReq->getRequestData());
- }
-
-}
\ No newline at end of file
diff --git a/src/Command/Mc/SendSMSTest.php b/src/Command/Mc/SendSMSTest.php
deleted file mode 100644
index 98d6b69..0000000
--- a/src/Command/Mc/SendSMSTest.php
+++ /dev/null
@@ -1,44 +0,0 @@
- array(
- "type" => "phone_num",
- "id" => "testbot"
- ),
- "to" => array(
- "type" => "phone_num",
- "id" => "123456789"
- ),
- "content" => array(
- "type" => "text",
- "text" => "hello world"
- ),
- "action" => "send-sms",
- );
-
- $req = new SendSMS();
- $req->setFrom("testbot");
- $req->setTo("123456789");
- $req->setContent("hello world");
- $this->assertEquals($params, $req->getRequestData());
- }
-
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage missing expected key `to` from Mocean\Command\Mc\SendSMS
- */
- public function testRequiredField()
- {
- $req = new SendSMS();
- $req->getRequestData();
- }
-}
\ No newline at end of file
diff --git a/src/Command/Mc/TgRequestContactTest.php b/src/Command/Mc/TgRequestContactTest.php
deleted file mode 100644
index 7ce7f63..0000000
--- a/src/Command/Mc/TgRequestContactTest.php
+++ /dev/null
@@ -1,49 +0,0 @@
- array(
- "button_text" => "Share contact",
- "button_request" => "contact"
- ),
- "from" => array(
- "type" => "bot_username",
- "id" => "testbot"
- ),
- "to" => array(
- "type" => "chat_id",
- "id" => "123456789"
- ),
- "content" => array(
- "type" => "text",
- "text" => "hello world"
- ),
- "action" => "send-telegram",
- );
-
- $req = new TgRequestContact();
- $req->setFrom("testbot");
- $req->setTo("123456789");
- $req->setContent("hello world");
- $req->setButtonText("Share contact");
- $this->assertEquals($params, $req->getRequestData());
- }
-
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage missing expected key `to` from Mocean\Command\Mc\TgRequestContact
- */
- public function testRequiredField()
- {
- $req = new TgRequestContact();
- $req->getRequestData();
- }
-}
\ No newline at end of file
diff --git a/src/Command/Mc/TgSendAnimationTest.php b/src/Command/Mc/TgSendAnimationTest.php
deleted file mode 100644
index e8f55de..0000000
--- a/src/Command/Mc/TgSendAnimationTest.php
+++ /dev/null
@@ -1,45 +0,0 @@
- array(
- "type" => "bot_username",
- "id" => "testbot"
- ),
- "to" => array(
- "type" => "chat_id",
- "id" => "123456789"
- ),
- "content" => array(
- "type" => "animation",
- "rich_media_url" => "https://moceanapi.com",
- "text" => "hello world"
- ),
- "action" => "send-telegram",
- );
-
- $req = new TgSendAnimation();
- $req->setFrom("testbot");
- $req->setTo("123456789");
- $req->setContent("https://moceanapi.com","hello world");
- $this->assertEquals($params, $req->getRequestData());
- }
-
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage missing expected key `to` from Mocean\Command\Mc\TgSendAnimation
- */
- public function testRequiredField()
- {
- $req = new TgSendAnimation();
- $req->getRequestData();
- }
-}
\ No newline at end of file
diff --git a/src/Command/Mc/TgSendAudioTest.php b/src/Command/Mc/TgSendAudioTest.php
deleted file mode 100644
index beb09f5..0000000
--- a/src/Command/Mc/TgSendAudioTest.php
+++ /dev/null
@@ -1,45 +0,0 @@
- array(
- "type" => "bot_username",
- "id" => "testbot"
- ),
- "to" => array(
- "type" => "chat_id",
- "id" => "123456789"
- ),
- "content" => array(
- "type" => "audio",
- "rich_media_url" => "https://moceanapi.com",
- "text" => "hello world"
- ),
- "action" => "send-telegram",
- );
-
- $req = new TgSendAudio();
- $req->setFrom("testbot");
- $req->setTo("123456789");
- $req->setContent("https://moceanapi.com","hello world");
- $this->assertEquals($params, $req->getRequestData());
- }
-
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage missing expected key `to` from Mocean\Command\Mc\TgSendAudio
- */
- public function testRequiredField()
- {
- $req = new TgSendAudio();
- $req->getRequestData();
- }
-}
\ No newline at end of file
diff --git a/src/Command/Mc/TgSendDocumentTest.php b/src/Command/Mc/TgSendDocumentTest.php
deleted file mode 100644
index 943a41a..0000000
--- a/src/Command/Mc/TgSendDocumentTest.php
+++ /dev/null
@@ -1,45 +0,0 @@
- array(
- "type" => "bot_username",
- "id" => "testbot"
- ),
- "to" => array(
- "type" => "chat_id",
- "id" => "123456789"
- ),
- "content" => array(
- "type" => "document",
- "rich_media_url" => "https://moceanapi.com",
- "text" => "hello world"
- ),
- "action" => "send-telegram",
- );
-
- $req = new TgSendDocument();
- $req->setFrom("testbot");
- $req->setTo("123456789");
- $req->setContent("https://moceanapi.com","hello world");
- $this->assertEquals($params, $req->getRequestData());
- }
-
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage missing expected key `to` from Mocean\Command\Mc\TgSendDocument
- */
- public function testRequiredField()
- {
- $req = new TgSendDocument();
- $req->getRequestData();
- }
-}
\ No newline at end of file
diff --git a/src/Command/Mc/TgSendPhotoTest.php b/src/Command/Mc/TgSendPhotoTest.php
deleted file mode 100644
index e9b8e63..0000000
--- a/src/Command/Mc/TgSendPhotoTest.php
+++ /dev/null
@@ -1,45 +0,0 @@
- array(
- "type" => "bot_username",
- "id" => "testbot"
- ),
- "to" => array(
- "type" => "chat_id",
- "id" => "123456789"
- ),
- "content" => array(
- "type" => "photo",
- "rich_media_url" => "https://moceanapi.com",
- "text" => "hello world"
- ),
- "action" => "send-telegram",
- );
-
- $req = new TgSendPhoto();
- $req->setFrom("testbot");
- $req->setTo("123456789");
- $req->setContent("https://moceanapi.com","hello world");
- $this->assertEquals($params, $req->getRequestData());
- }
-
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage missing expected key `to` from Mocean\Command\Mc\TgSendPhoto
- */
- public function testRequiredField()
- {
- $req = new TgSendPhoto();
- $req->getRequestData();
- }
-}
\ No newline at end of file
diff --git a/src/Command/Mc/TgSendTextTest.php b/src/Command/Mc/TgSendTextTest.php
deleted file mode 100644
index 6e5a2a8..0000000
--- a/src/Command/Mc/TgSendTextTest.php
+++ /dev/null
@@ -1,44 +0,0 @@
- array(
- "type" => "bot_username",
- "id" => "testbot"
- ),
- "to" => array(
- "type" => "chat_id",
- "id" => "123456789"
- ),
- "content" => array(
- "type" => "text",
- "text" => "hello world"
- ),
- "action" => "send-telegram",
- );
-
- $req = new TgSendText();
- $req->setFrom("testbot");
- $req->setTo("123456789");
- $req->setContent("hello world");
- $this->assertEquals($params, $req->getRequestData());
- }
-
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage missing expected key `to` from Mocean\Command\Mc\TgSendText
- */
- public function testRequiredField()
- {
- $req = new TgSendText();
- $req->getRequestData();
- }
-}
\ No newline at end of file
diff --git a/src/Command/Mc/TgSendVideoTest.php b/src/Command/Mc/TgSendVideoTest.php
deleted file mode 100644
index 4959314..0000000
--- a/src/Command/Mc/TgSendVideoTest.php
+++ /dev/null
@@ -1,45 +0,0 @@
- array(
- "type" => "bot_username",
- "id" => "testbot"
- ),
- "to" => array(
- "type" => "chat_id",
- "id" => "123456789"
- ),
- "content" => array(
- "type" => "video",
- "rich_media_url" => "https://moceanapi.com",
- "text" => "hello world"
- ),
- "action" => "send-telegram",
- );
-
- $req = new TgSendVideo();
- $req->setFrom("testbot");
- $req->setTo("123456789");
- $req->setContent("https://moceanapi.com","hello world");
- $this->assertEquals($params, $req->getRequestData());
- }
-
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage missing expected key `to` from Mocean\Command\Mc\TgSendVideo
- */
- public function testRequiredField()
- {
- $req = new TgSendVideo();
- $req->getRequestData();
- }
-}
\ No newline at end of file
diff --git a/src/Command/McBuilderTest.php b/src/Command/McBuilderTest.php
deleted file mode 100644
index c75d12c..0000000
--- a/src/Command/McBuilderTest.php
+++ /dev/null
@@ -1,41 +0,0 @@
-assertInstanceOf(McBuilder::class, new McBuilder());
- $this->assertInstanceOf(McBuilder::class, McBuilder::create());
- }
-
- public function testAdd()
- {
- $tgSendText = Mc::tgSendText()
- ->setFrom("botusername")
- ->setTo("123456789")
- ->setContent("Hello world");
-
- $req = McBuilder::create();
- $req->add($tgSendText);
- }
-
- public function testBuild()
- {
- $tgSendText = Mc::tgSendText()
- ->setFrom("botusername")
- ->setTo("123456789")
- ->setContent("Hello world");
-
- $req = McBuilder::create();
- $req->add($tgSendText);
-
- $this->assertCount(1,$req->build());
- $this->assertEquals($tgSendText->getRequestData(),$req->build()[0]);
- }
-}
\ No newline at end of file
diff --git a/src/Command/McTest.php b/src/Command/McTest.php
deleted file mode 100644
index 43a2f4e..0000000
--- a/src/Command/McTest.php
+++ /dev/null
@@ -1,46 +0,0 @@
-assertInstanceOf(TgSendText::class, Mc::tgSendText());
- }
-
- public function testTgSendAudio()
- {
- $this->assertInstanceOf(TgSendAudio::class, Mc::tgSendAudio());
- }
-
- public function testTgSendAnimation()
- {
- $this->assertInstanceOf(TgSendAnimation::class, Mc::tgSendAnimation());
- }
-
- public function testTgSendDocument()
- {
- $this->assertInstanceOf(TgSendDocument::class, Mc::tgSendDocument());
- }
-
- public function testTgSendVideo()
- {
- $this->assertInstanceOf(TgSendVideo::class, Mc::tgSendVideo());
- }
-
- public function testTgRequestContact()
- {
- $this->assertInstanceOf(TgRequestContact::class, Mc::tgRequestContact());
- }
-}
\ No newline at end of file
diff --git a/test/Command/CommanderTest.php b/test/Command/CommanderTest.php
index ad83934..be77d50 100644
--- a/test/Command/CommanderTest.php
+++ b/test/Command/CommanderTest.php
@@ -7,6 +7,16 @@
class CommanderTest extends AbstractTesting
{
+
+ protected function setUp():void
+ {
+ $this->mockJsonResponseStr = $this->getResponseString('command.json');
+ $this->mockXmlResponseStr = $this->getResponseString('command.xml');
+
+ $this->jsonResponse = \Mocean\Command\Commander::createFromResponse($this->mockJsonResponseStr, $this->defaultVersion);
+ $this->xmlResponse = \Mocean\Command\Commander::createFromResponse($this->mockXmlResponseStr, $this->defaultVersion);
+ }
+
public function testRequestDataParams()
{
$params = [