I have written some unit tests in my Laravel project and trying to execute them through a third party app. I can execute these tests in the command line with phpunit but my requirement is to run them externally(to automate). Is that possible at all? It seems my custom classes/Laravel helper classes are not accessible when running them externally.
use App\ZZZ\Scrape;
use App\ZZZ\Theme1;
use App\ZZZ\Theme2;
class ScrapeTest extends TestCase
{
protected static $scrape;
protected static $sxe;
protected static $theme;
protected static $url;
protected static $section;
protected static $extArray;
protected static $intArray;
protected static $safetyArray;
protected static $perfArray;
protected static $output;
public static function setUpBeforeClass()
{
Config::set('aws.s3Path', 'zz/test/');
self::$url = "http://www.testsite.com.au";
self::$section = "testSection";
self::$scrape = new Scrape(self::$url, self::$section);
self::$scrape->html = self::$scrape->getHTML();
self::$sxe = self::$scrape->getSimpleXmlElement();
if(self::$scrape->isDarkTheme(self::$sxe))
{
self::$theme = new Theme1(self::$url,self::$section);
}
else
self::$theme = new Theme2(self::$url,self::$section);
self::$output = new stdClass();
//exterior features
self::$extArray = self::$theme->getFeatureDetails(self::$sxe, "exterior");
self::$output->ExteriorFeatures = new stdClass();
self::$output->ExteriorFeatures->Feature = self::$extArray;
//interior features
self::$intArray = self::$theme->getFeatureDetails(self::$sxe, "interior");
self::$output->InteriorFeatures = new stdClass();
self::$output->InteriorFeatures->Feature = self::$intArray;
}
public function testGetLeadingText()
{
$result = self::$scrape->getLeadingText(self::$sxe);
$this->assertNotNull($result, "No leading text");
}
public function testFetchColours()
{
$result = self::$scrape->FetchColours();
$this->assertNotNull($result, "Error with decoding colour API");
$this->assertInternalType('array', $result->data, "FetchAPI output is not an array");
$this->assertNotSame(null, $result->data, "FetchAPI output is an empty array");
}
}
Some of the errors I get:
Class 'TestCase' not found in C:...\ScrapeTest.php
Class 'Config' not found in C:...\ScrapeTest.php
Class 'App\ZZZ\Scrape' not found in C:...\ScrapeTest.php ...
Any help is very much appreciated. Thanks in advance.
UnitTest.php
content – PaladiN