Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Switched to Symfony DI for classes
  • Loading branch information
samtuke committed Mar 17, 2016
1 parent da47aeb commit 69890dc
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions plugins/restapi2/tests/P4Test.php
Expand Up @@ -25,30 +25,17 @@ class Pl4Test extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
// Access the Symfony DI container object which was setup during bootstrap
global $container;
$this->container = $container;

// Create a randomised email addy to register with
$this->emailAddress = 'unittest-' . rand( 0, 999999 ) . '@example.com';
$this->plainPass = 'easypassword';

// Get objects from container
$this->config = $this->container->get( 'Config' );

// Instantiate util classes
$this->emailUtil = new EmailUtil();
$this->pass = new Pass();

// Instantiate remaining classes
$this->db = new Database( $this->config );
$this->subscriberModel = new SubscriberModel( $this->config, $this->db );
$this->subscriberManager = new SubscriberManager(
$this->config
, $this->emailUtil
, $this->pass
, $this->subscriberModel
);
// Create Symfony DI service container object for use by other classes
$this->container = new ContainerBuilder();
// Create new Symfony file loader to handle the YAML service config file
$loader = new YamlFileLoader( $this->container, new FileLocator(__DIR__) );
// Load the service config file, which is in YAML format
$loader->load( '../services.yml' );
$this->subscriberManager = $this->container->get( 'SubscriberManager' );
}

/**
Expand All @@ -57,7 +44,10 @@ public function setUp()
public function testAdd()
{
// Add new subscriber properties to the entity
$scrEntity = new SubscriberEntity( $this->emailAddress, $this->plainPass );
$scrEntity = new SubscriberEntity;
$scrEntity->emailAddress = $this->emailAddress;
$scrEntity->plainPass = $this->plainPass;

// Copy the email address to test it later
$emailCopy = $this->emailAddress;
// Save the subscriber
Expand Down

0 comments on commit 69890dc

Please sign in to comment.