Skip to content

Commit

Permalink
Initial tests
Browse files Browse the repository at this point in the history
  • Loading branch information
peter279k committed Dec 30, 2018
1 parent 30b96b3 commit 3aa5de6
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
language: php
dist: trusty
sudo: true
php:
- '7.1'
- '7.2'
- nightly
matrix:
allow_failures:
- php: nightly
install:
- composer install
script:
- ./vendor/bin/phpunit
11 changes: 10 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,20 @@
"license": "LGPL-3.0-only",
"require": {
"ivopetkov/html5-dom-document-php": "^1.1",
"nesbot/carbon": "^2.7"
"nesbot/carbon": "^2.7",
"php": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "^7.0"
},
"autoload": {
"psr-4": {
"DivineOmega\\GitHubStatusApi\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"DivineOmega\\GitHubStatusApi\\Tests\\": "tests/"
}
}
}
24 changes: 24 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Unit Tests">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src</directory>
<exclude>
<directory suffix=".php">src/Examples</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
53 changes: 53 additions & 0 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace DivineOmega\GitHubStatusApi;

use DivineOmega\GitHubStatusApi\Client;
use DivineOmega\GitHubStatusApi\Enums\GitHubStatus;
use PHPUnit\Framework\TestCase;

class ClientTest extends TestCase
{
public function testStatusShouldReturnGood()
{
$mockedClient = $this->createMock(Client::class);
$mockedClient->method('status')
->willReturn(GitHubStatus::GOOD);

$this->assertSame(GitHubStatus::GOOD, $mockedClient->status());
}

public function testStatusShouldReturnMinor()
{
$mockedClient = $this->createMock(Client::class);
$mockedClient->method('status')
->willReturn(GitHubStatus::MINOR);

$this->assertSame(GitHubStatus::MINOR, $mockedClient->status());
}

public function testStatusShouldReturnMajor()
{
$mockedClient = $this->createMock(Client::class);
$mockedClient->method('status')
->willReturn(GitHubStatus::MAJOR);

$this->assertSame(GitHubStatus::MAJOR, $mockedClient->status());
}

public function testStatusShouldReturnuUnknown()
{
$mockedClient = $this->createMock(Client::class);
$mockedClient->method('status')
->willReturn(GitHubStatus::UNKNOWN);

$this->assertSame(GitHubStatus::UNKNOWN, $mockedClient->status());
}

public function testStatusWillReturnGood()
{
$mockedClient = (new Client())->status();

$this->assertSame(GitHubStatus::GOOD, $mockedClient->status());
}
}

0 comments on commit 3aa5de6

Please sign in to comment.