Skip to content

Commit

Permalink
Add new tests for better coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémi Sauvat committed Aug 28, 2015
1 parent da7779d commit 4a1b745
Show file tree
Hide file tree
Showing 7 changed files with 491 additions and 2 deletions.
9 changes: 9 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@
<ini name="error_reporting" value="30719"/>
</php>
<testsuites>
<!-- unit tests on EntryPoint must run first because it can be instantiated only once -->
<testsuite name="EntryPoint">
<file>tests/EntryPointTest.php</file>
</testsuite>
<testsuite name="Inet">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
1 change: 0 additions & 1 deletion src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public function isInstalled()
return $sugarConfig['installer_locked'];
}
} catch (SugarException $e) {
return false;
}
return false;
}
Expand Down
12 changes: 12 additions & 0 deletions tests/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public function testSugarPath()
$this->assertEquals(realpath($sugarDir), $app->getPath());
$this->assertTrue($app->isValid());
$this->assertTrue($app->isInstalled());

$app = new Application(__DIR__ . '/invalid_sugar');
$this->assertFalse($app->isInstalled());
}

/**
Expand Down Expand Up @@ -98,4 +101,13 @@ public function testGetVersion()
);
$this->assertEquals($expected, $sugar->getVersion());
}

/**
* @expectedException \Inet\SugarCrm\SugarException
*/
public function testInvalidVersion()
{
$sugar = new Application(__DIR__);
$sugar->getVersion();
}
}
20 changes: 19 additions & 1 deletion tests/EntryPointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,32 @@ class EntryPointTest extends SugarTestCase
/** Define a wrong folder: exception thrown
* @expectedException \Inet\SugarCRM\SugarException
* @expectedExceptionMessageRegExp #Unable to find an installed instance of SugarCRM in :/foo#
* @runInSeparateProcess
*/
public function testWrongInstanciationBadFolder()
{
$logger = new NullLogger;
EntryPoint::createInstance($logger, new Application('/foo'), '1');
}

/**
* @expectedException \RuntimeException
* @expectedExceptionMessageRegExp #You must first create the singleton instance with createInstance().#
*/
public function testGetInstanceFailure()
{
EntryPoint::getInstance();
}

/**
* @expectedException \RuntimeException
* @expectedExceptionMessageRegExp #Unable to create a SugarCRM\\EntryPoint more than once.#
*/
public function testCreateInstanceFailure()
{
$this->getEntryPointInstance();
EntryPoint::createInstance(new NullLogger, new Application('/foo'), '1');
}

public function testGettersSetters()
{
$entryPoint = $this->getEntryPointInstance();
Expand Down
Loading

0 comments on commit 4a1b745

Please sign in to comment.