* @license http://opensource.org/licenses/MIT MIT * @version GIT: <git_id> * @link http://donbstringham.us * $LastChangedDate$ * $LastChangedBy$ */ use Emris\Cli\Scaler\Domain\ServerBuilder; use Emris\Cli\Scaler\Domain\ServerCollection; describe('Emris\\Cli\\Scaler\\Domain\\ServerCollection', function () { beforeEach(function () { require 'container.data.php'; $builder = new ServerBuilder(); /** @var string $serverData01 */ $builder->setIp('127.0.0.1'); $builder->setPort('8080'); $this->server01 = $builder->build(); /** @var string $serverData02 */ $builder->setIp('127.0.0.2'); $builder->setPort('8081'); $this->server02 = $builder->build(); /** @var string $serverData03 */ $builder->setIp('127.0.0.3'); $builder->setPort('8081'); $this->server03 = $builder->build(); $this->collection = new ServerCollection([$this->server01, $this->server02, $this->server03]); }); describe('->__construct()', function () { it('should return a ServerCollection object', function () { expect($this->collection)->to->be->instanceof('Emris\\Cli\\Scaler\\Domain\\ServerCollection'); }); });
use Emris\Cli\Scaler\Domain\Services\LoadBalancerManager; describe('Emris\\Cli\\Scaler\\Domain\\Services\\LoadBalancerManager', function () { beforeEach(function () { $this->adapterMock = $this->getProphet()->prophesize('Emris\\Cli\\Scaler\\Domain\\Services\\LoadBalancerAdapter'); $this->srvrMgr = new LoadBalancerManager($this->adapterMock->reveal()); }); describe('->__construct()', function () { it('should return a LoadBalancerManager object', function () { expect($this->srvrMgr)->to->be->instanceof('Emris\\Cli\\Scaler\\Domain\\Services\\LoadBalancerManager'); }); }); describe('->servers()', function () { beforeEach(function () { $srvrBldr = new ServerBuilder(); $servers = new ServerCollection(); $servers->add($srvrBldr->build()); $servers->add($srvrBldr->build()); $servers->add($srvrBldr->build()); $this->adapterMock->servers()->willReturn($servers); }); it('should return a ServerCollection of 3 objects', function () { /** @var \Emris\Cli\Scaler\Domain\ServerCollection $actual */ $actual = $this->srvrMgr->servers(); expect($actual)->to->be->instanceof('Emris\\Cli\\Scaler\\Domain\\ServerCollection'); expect($actual->count())->to->equal(3); }); }); describe('->add($servers)', function () { beforeEach(function () { $this->srvrBldr = new ServerBuilder(); $this->adapterMock->addServer($this->srvrBldr->build())->willReturn(true);
}); describe('->__construct()', function () { it('should return a Container and ContainerBuilder object', function () { expect($this->builder)->to->be->instanceof('Emris\\Cli\\Scaler\\Domain\\ContainerBuilder'); $container = $this->builder->build(); expect($container)->to->be->instanceof('Emris\\Cli\\Scaler\\Domain\\Container'); }); }); describe('->buildFrom($server)', function () { it('should return a Container object', function () { $svrBldr = new ServerBuilder(); $svrBldr->setId('0'); $svrBldr->setName('/emrisalarmwebservice_eaws_php_1'); $svrBldr->setIp('127.0.0.1'); $svrBldr->setPort(9000); $server = $svrBldr->build(); $container = $this->builder->buildFrom($server); expect($container)->to->be->instanceof('Emris\\Cli\\Scaler\\Domain\\Container'); }); }); describe('->setJson($json)', function () { it('should return take json can convert it to metadata', function () { require 'container.data.php'; /** @var string $containerData01 */ $this->builder->setJson($containerData01); /** @var \Emris\Cli\Scaler\Domain\Container $container */ $container = $this->builder->build(); $metadata = $container->getMetadata(); expect($container)->to->be->instanceof('Emris\\Cli\\Scaler\\Domain\\Container'); expect($metadata['Driver'])->to->equal('aufs'); expect($metadata['Name'])->to->equal('/sharp_wescoff');