Skip to content

Commit

Permalink
Merge pull request #13 from goodjun/dev
Browse files Browse the repository at this point in the history
optimize test case
  • Loading branch information
goodjun authored Sep 23, 2020
2 parents 207e9b8 + 9906c65 commit 29d8a26
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/LUIS/Tests/Models/AppTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace LUIS\Tests\Models;

use Goodjun\LUIS\Models\App;

class AppTest extends \PHPUnit_Framework_TestCase
{
public function testConstruct()
{
$app = new App([
'name' => 'name',
'description' => 'description',
'domain' => 'domain',
'culture' => 'en-us',
'tokenizerVersion' => '1.0',
'usageScenario' => 'usage',
'initialVersionId' => '0.1',
]);

$this->assertEquals('name', $app->getName());
$this->assertEquals('description', $app->getDescription());
$this->assertEquals('domain', $app->getDomain());
$this->assertEquals('en-us', $app->getCulture());
$this->assertEquals('0.1', $app->getInitialVersionId());
$this->assertEquals('1.0', $app->getTokenizerVersion());
$this->assertEquals('usage', $app->getUsageScenario());
}

public function testSetterGetter()
{
$app = new App();

$app->setName('name')
->setDescription('description')
->setDomain('domain')
->setCulture('en-us')
->setInitialVersionId('0.1')
->setTokenizerVersion('1.0')
->setUsageScenario('usage');

$this->assertEquals('name', $app->getName());
$this->assertEquals('description', $app->getDescription());
$this->assertEquals('domain', $app->getDomain());
$this->assertEquals('en-us', $app->getCulture());
$this->assertEquals('0.1', $app->getInitialVersionId());
$this->assertEquals('1.0', $app->getTokenizerVersion());
$this->assertEquals('usage', $app->getUsageScenario());
}
}
17 changes: 17 additions & 0 deletions tests/LUIS/Tests/Models/ModelAbstractTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace LUIS\Tests\Models;

use Goodjun\LUIS\Models\ModelAbstract;

class ModelAbstractTest extends \PHPUnit_Framework_TestCase
{
public function testToArray()
{
$stub = $this->getMockForAbstractClass(ModelAbstract::class);

$stub->expects($this->any())
->method('toArray')
->will($this->returnValue([]));
}
}
34 changes: 34 additions & 0 deletions tests/LUIS/Tests/Models/UtteranceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace LUIS\Tests\Models;

use Goodjun\LUIS\Models\Utterance;

class UtteranceTest extends \PHPUnit_Framework_TestCase
{
public function testConstruct()
{
$utterance = new Utterance([
'text' => 'text',
'intentName' => 'intent name',
'entityLabels' => [],
]);

$this->assertEquals('text', $utterance->getText());
$this->assertEquals('intent name', $utterance->getIntentName());
$this->assertEquals([], $utterance->getEntityLabels());
}

public function testSetterGetter()
{
$utterance = new Utterance();

$utterance->setText('text')
->setIntentName('intent name')
->setEntityLabels([]);

$this->assertEquals('text', $utterance->getText());
$this->assertEquals('intent name', $utterance->getIntentName());
$this->assertEquals([], $utterance->getEntityLabels());
}
}
4 changes: 4 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

$classLoader = require dirname(__DIR__).'/vendor/autoload.php';
$classLoader->register(true);

0 comments on commit 29d8a26

Please sign in to comment.