Exemple #1
0
 /**
  * @group           HasMany
  * @group           HasManyConstruct
  * @covers          FOF30\Model\DataModel\Relation\HasMany::__construct
  * @dataProvider    HasManyDataprovider::getTestConstruct
  */
 public function testConstruct($test, $check)
 {
     $msg = 'HasMany::__construct %s - Case: ' . $check['case'];
     $model = $this->buildModel();
     $relation = new HasMany($model, 'Children', $test['local'], $test['foreign']);
     $this->assertEquals($check['local'], ReflectionHelper::getValue($relation, 'localKey'), sprintf($msg, 'Failed to set the local key'));
     $this->assertEquals($check['foreign'], ReflectionHelper::getValue($relation, 'foreignKey'), sprintf($msg, 'Failed to set the foreign key'));
 }
Exemple #2
0
 /**
  * @group       AbstractFilter
  * @group       AbstractFilterConstruct
  * @covers      FOF30\Model\DataModel\Filter\AbstractFilter::__construct
  */
 public function test__construct()
 {
     $db = \JFactory::getDbo();
     $field = (object) array('name' => 'test', 'type' => 'test');
     $filter = new FilterStub($db, $field);
     $this->assertEquals('test', ReflectionHelper::getValue($filter, 'name'), 'AbstractFilter::__construct Failed to set the field name');
     $this->assertEquals('test', ReflectionHelper::getValue($filter, 'type'), 'AbstractFilter::__construct Failed to set the fiel type');
 }
Exemple #3
0
 /**
  * @covers  FOF30\Timer\Timer::resetTime
  */
 public function testResetTime()
 {
     FakeTimer::$microtime = 123456;
     $timer = new Timer(8, 33);
     FakeTimer::$microtime = 876543.21;
     $timer->resetTime();
     $this->assertEquals(876543.21, ReflectionHelper::getValue($timer, 'start_time'), 'Resetting the timer must read a new value from microtime', 1.0E-10);
 }
Exemple #4
0
 /**
  * @group       RelationFilter
  * @group       RelationFilterConstruct
  * @covers      FOF30\Model\DataModel\Filter\Relation::__construct
  */
 public function test__construct()
 {
     $subquery = \JFactory::getDbo()->getQuery(true);
     $subquery->select('*')->from('test');
     $filter = new Relation(\JFactory::getDbo(), 'foo', $subquery);
     $this->assertEquals('foo', ReflectionHelper::getValue($filter, 'name'), 'Relation::__construct Failed to set filter name');
     $this->assertEquals('relation', ReflectionHelper::getValue($filter, 'type'), 'Relation::__construct Failed to set filter type');
     $this->assertEquals($subquery, ReflectionHelper::getValue($filter, 'subQuery'), 'Relation::__construct Failed to set the subQuery field');
 }
 public function testRemoveAuthenticationMethod()
 {
     $this->auth->setAuthenticationMethods(array(TransparentAuthentication::Auth_HTTPBasicAuth_Plaintext, TransparentAuthentication::Auth_HTTPBasicAuth_TOTP));
     // Try removing a non-existing method
     $this->auth->removeAuthenticationMethod(TransparentAuthentication::Auth_QueryString_Plaintext);
     $this->assertEquals(array(TransparentAuthentication::Auth_HTTPBasicAuth_Plaintext, TransparentAuthentication::Auth_HTTPBasicAuth_TOTP), ReflectionHelper::getValue($this->auth, 'authenticationMethods'));
     // Try removing an existing method
     $this->auth->removeAuthenticationMethod(TransparentAuthentication::Auth_HTTPBasicAuth_Plaintext);
     $this->assertEquals(array(1 => TransparentAuthentication::Auth_HTTPBasicAuth_TOTP), ReflectionHelper::getValue($this->auth, 'authenticationMethods'));
 }
Exemple #6
0
 /**
  * @covers  FOF30\Download\Adapter\Fopen::__construct
  */
 public function testConstructor()
 {
     $adapter = new Fopen();
     $this->assertInstanceOf('FOF30\\Download\\Adapter\\Fopen', $adapter, 'Adapter must match correct object type');
     $this->assertEquals(100, ReflectionHelper::getValue($adapter, 'priority'), 'Adapter priority must match');
     $this->assertEquals(false, ReflectionHelper::getValue($adapter, 'supportsFileSize'), 'Adapter must not support file size');
     $this->assertEquals(true, ReflectionHelper::getValue($adapter, 'supportsChunkDownload'), 'Adapter must support chunked download');
     $this->assertEquals('fopen', ReflectionHelper::getValue($adapter, 'name'), 'Adapter must have the correct name');
     $this->assertEquals(true, ReflectionHelper::getValue($adapter, 'isSupported'), 'Adapter must be supported');
 }
Exemple #7
0
 /**
  * @group           Behaviour
  * @group           EnabledOnBeforeBuildQuery
  * @covers          FOF30\Model\DataModel\Behaviour\Enabled::onBeforeBuildQuery
  * @dataProvider    EnabledDataprovider::getTestOnBeforeBuildQuery
  */
 public function testOnBeforeBuildQuery($test, $check)
 {
     $msg = 'Own::onAfterBuildQuery %s - Case: ' . $check['case'];
     $config = array('idFieldName' => $test['tableid'], 'tableName' => $test['table']);
     $model = new DataModelStub(static::$container, $config);
     $query = \JFactory::getDbo()->getQuery(true)->select('*')->from('test');
     $dispatcher = $model->getBehavioursDispatcher();
     $behavior = new Enabled($dispatcher);
     $behavior->onBeforeBuildQuery($model, $query);
     $where = ReflectionHelper::getValue($model, 'whereClauses');
     $this->assertCount($check['count'], $where, sprintf($msg, 'Failed to set the where'));
 }
Exemple #8
0
 /**
  * @covers FOF30\Download\Download::setAdapter
  *
  * @dataProvider    FOF30\Tests\Download\DownloadDataprovider::getTestSetAdapter
  */
 public function testSetAdapter($className, $shouldChange = true)
 {
     $download = new Download(static::$container);
     $download->setAdapter('curl');
     $this->assertInstanceOf('\\FOF30\\Download\\Adapter\\Curl', ReflectionHelper::getValue($download, 'adapter'), 'Initially forced adapter should be cURL');
     $download->setAdapter($className);
     if ($shouldChange) {
         $this->assertNotInstanceOf('\\FOF30\\Download\\Adapter\\Curl', ReflectionHelper::getValue($download, 'adapter'), 'Forced adapter should be NOT still be cURL');
     } else {
         $this->assertInstanceOf('\\FOF30\\Download\\Adapter\\Curl', ReflectionHelper::getValue($download, 'adapter'), 'Forced adapter should still be cURL');
     }
 }
Exemple #9
0
 /**
  * @group           DataViewRaw
  * @covers          FOF30\View\DataView\Raw::__construct
  * @dataProvider    RawDataprovider::getTest__construct
  */
 public function test__construct($test, $check)
 {
     $msg = 'Raw::__construct %s - Case: ' . $check['case'];
     $platform = static::$container->platform;
     $platform::$uriBase = 'www.example.com';
     $platform::$template = 'fake_test_template';
     $platform::$isCli = $test['mock']['isCli'];
     $platform::$authorise = function () {
         return false;
     };
     $view = new RawStub(static::$container);
     $permissions = ReflectionHelper::getValue($view, 'permissions');
     $this->assertEquals($check['permissions'], $permissions, sprintf($msg, 'Failed to set the permissions'));
 }
Exemple #10
0
 /**
  * @group           BelongsToMany
  * @group           BelongsToManySetDataFromCollection
  * @covers          FOF30\Model\DataModel\Relation\BelongsToMany::setDataFromCollection
  * @dataProvider    BelongsToManyDataprovider::getTestSetDataFromCollection
  */
 public function testSetDataFromCollection($test, $check)
 {
     $msg = 'BelongsToMany::setDataFromCollection %s - Case: ' . $check['case'];
     $parts = new Parts(static::$container);
     $model = new Groups(static::$container);
     $model->find(2);
     $relation = new BelongsToMany($model, 'Parts');
     $items[0] = clone $parts;
     $items[0]->find(1);
     $items[1] = clone $parts;
     $items[1]->find(2);
     $items[2] = clone $parts;
     $items[2]->find(3);
     $data = new Collection($items);
     $relation->setDataFromCollection($data, $test['keymap']);
     $this->assertCount($check['count'], ReflectionHelper::getValue($relation, 'data'), sprintf($msg, ''));
 }
Exemple #11
0
 /**
  * @covers        FOF30\Input\Input::__construct
  *
  * @dataProvider  FOF30\Tests\Input\InputProvider::getTestConstructor
  *
  * @backupGlobals enabled
  */
 public function testConstructor($source, $superGlobals, $match, $message)
 {
     // Initialise superglobals for this test
     $_GET = isset($superGlobals['get']) ? $superGlobals['get'] : array();
     $_POST = isset($superGlobals['post']) ? $superGlobals['post'] : array();
     $_FILES = isset($superGlobals['files']) ? $superGlobals['files'] : array();
     $_COOKIE = isset($superGlobals['cookie']) ? $superGlobals['cookie'] : array();
     $_ENV = isset($superGlobals['env']) ? $superGlobals['env'] : array();
     $_SERVER = isset($superGlobals['server']) ? $superGlobals['server'] : array();
     $_REQUEST = isset($superGlobals['request']) ? $superGlobals['request'] : array();
     $input = new Input($source);
     $data = ReflectionHelper::getValue($input, 'data');
     $this->assertInternalType('array', $data, $message);
     foreach ($match as $k => $v) {
         $this->assertArrayHasKey($k, $data, $message);
         $this->assertEquals($v, $data[$k], $message);
     }
 }
Exemple #12
0
 /**
  * @covers          FOF30\Dispatcher\Dispatcher::__construct
  * @dataProvider    DispatcherDataprovider::getTest__construct
  */
 public function test__construct($test, $check)
 {
     $msg = 'Dispatcher::__construct %s - Case: ' . $check['case'];
     $container = new TestContainer(array('input' => new Input($test['mock']['input'])));
     $config = array();
     if ($test['mock']['defaultView']) {
         $config['defaultView'] = $test['mock']['defaultView'];
     }
     $dispatcher = new Dispatcher($container, $config);
     $defView = ReflectionHelper::getValue($dispatcher, 'defaultView');
     $view = ReflectionHelper::getValue($dispatcher, 'view');
     $layout = ReflectionHelper::getValue($dispatcher, 'layout');
     $containerView = $container->input->get('view', null);
     $this->assertEquals($check['defaultView'], $defView, sprintf($msg, 'Failed to set the default view'));
     $this->assertEquals($check['view'], $view, sprintf($msg, 'Failed to set the view'));
     $this->assertEquals($check['layout'], $layout, sprintf($msg, 'Failed to set the layout'));
     $this->assertEquals($check['containerView'], $containerView, sprintf($msg, 'Failed to correctly update the container input'));
 }
Exemple #13
0
 /**
  * @covers          FOF30\Factory\Magic\ControllerFactory::make
  * @dataProvider    ControllerFactoryDataprovider::getTestMake
  */
 public function testMake($test, $check)
 {
     $msg = 'ControllerFactory::make %s - Case: ' . $check['case'];
     $config['componentName'] = $test['component'];
     if ($test['backend_path']) {
         $config['backEndPath'] = $test['backend_path'];
     }
     $container = new TestContainer($config);
     // Required so we force FOF to read the fof.xml file
     $dummy = $container->appConfig;
     $factory = new ControllerFactory($container);
     if ($check['exception']) {
         $this->setExpectedException('FOF30\\Factory\\Exception\\ControllerNotFound');
     }
     $result = $factory->make($test['name'], $test['config']);
     $this->assertEquals($check['result'], get_class($result), sprintf($msg, 'Returned the wrong result'));
     $this->assertEquals($check['autoRouting'], ReflectionHelper::getValue($result, 'autoRouting'), sprintf($msg, 'Failed to set the autorouting'));
     $this->assertEquals($check['csrf'], ReflectionHelper::getValue($result, 'csrfProtection'), sprintf($msg, 'Failed to set the csrfProtection'));
     $this->assertEquals($check['view'], ReflectionHelper::getValue($result, 'viewName'), sprintf($msg, 'Failed to set the viewName'));
     $this->assertEquals($check['model'], ReflectionHelper::getValue($result, 'modelName'), sprintf($msg, 'Failed to set the modelName'));
     $this->assertEquals($check['priv'], ReflectionHelper::getValue($result, 'taskPrivileges'), sprintf($msg, 'Failed to set the taskPrivileges'));
     $this->assertEquals($check['cache'], ReflectionHelper::getValue($result, 'cacheableTasks'), sprintf($msg, 'Failed to set the cacheableTasks'));
     $this->assertEquals($check['taskMap'], ReflectionHelper::getValue($result, 'taskMap'), sprintf($msg, 'Failed to set the taskMap'));
 }
Exemple #14
0
 /**
  * @group           DataModel
  * @group           DataModelBlacklistFilters
  * @covers          FOF30\Model\DataModel::blacklistFilters
  * @dataProvider    DataModelGenericDataprovider::getTestBlacklistFilters
  */
 public function testBlacklistFilters($test, $check)
 {
     $msg = 'DataModel::blacklistFilters %s - Case: ' . $check['case'];
     $config = array('idFieldName' => 'foftest_bare_id', 'tableName' => '#__foftest_bares');
     $model = new DataModelStub(static::$container, $config);
     ReflectionHelper::setValue($model, '_behaviorParams', array('blacklistFilters' => array('test')));
     $result = $model->blacklistFilters($test['list'], $test['reset']);
     $behaviors = ReflectionHelper::getValue($model, '_behaviorParams');
     $filters = isset($behaviors['blacklistFilters']) ? $behaviors['blacklistFilters'] : array();
     $this->assertSame($check['result'], $result, sprintf($msg, 'Returned the wrong result'));
     $this->assertEquals($check['filters'], $filters, sprintf($msg, 'Failed to set the filters'));
 }
Exemple #15
0
 /**
  * @group           DataModel
  * @group           DataModelCall
  * @covers          FOF30\Model\DataModel::__call
  * @dataProvider    MagicMethodsDataprovider::getTest__call
  */
 public function test__call($test, $check)
 {
     $msg = 'DataModel::__call %s - Case: ' . $check['case'];
     $config = array('idFieldName' => 'foftest_foobar_id', 'tableName' => '#__foftest_foobars');
     $model = new DataModelStub(static::$container, $config);
     $relation = $this->getMock('\\FOF30\\Model\\DataModel\\RelationManager', array('isMagicMethod', '__call'), array($model));
     $relation->expects($check['magic'] ? $this->once() : $this->never())->method('isMagicMethod')->willReturn($test['mock']['magic']);
     $relation->expects($check['relationCall'] ? $this->once() : $this->never())->method('__call')->willReturn(null);
     ReflectionHelper::setValue($model, 'relationManager', $relation);
     $method = $test['method'];
     // I have to use this syntax to check when I don't pass any argument
     // N.B. If I use the __call syntax to set a property, I have to use a REAL property, otherwise the __set magic
     // method kicks in and its behavior it's out the scope of this test
     if (isset($test['argument'])) {
         $result = $model->{$method}($test['argument'][0], $test['argument'][1]);
     } else {
         $result = $model->{$method}();
     }
     $count = isset($model->methodCounter[$check['method']]) ? $model->methodCounter[$check['method']] : 0;
     $property = ReflectionHelper::getValue($model, $check['property']);
     if (is_object($result)) {
         $this->assertInstanceOf('\\FOF30\\Model\\DataModel', $result, sprintf($msg, 'Should return an instance of itself'));
     } else {
         $this->assertNull($result, sprintf($msg, 'Should return null when the relation manager is involved'));
     }
     $this->assertEquals($check['count'], $count, sprintf($msg, 'Invoked the specific caller method a wrong amount of times'));
     $this->assertEquals($check['value'], $property, sprintf($msg, 'Failed to set the property'));
 }
Exemple #16
0
 /**
  * @group           Relation
  * @group           RelationSetDataFromCollection
  * @covers          FOF30\Model\DataModel\Relation::setDataFromCollection
  */
 public function testSetDataFromCollection()
 {
     //\PHPUnit_Framework_Error_Warning::$enabled = false;
     $childrenModel = new \Fakeapp\Site\Model\Children(static::$container);
     $model = $this->buildModel();
     $model->find(2);
     $relation = new RelationStub($model, 'Children', 'fakeapp_parent_id', 'fakeapp_parent_id');
     $items[0] = clone $childrenModel;
     $items[1] = clone $childrenModel;
     $items[0]->find(1);
     // This child record IS NOT related to the current parent
     $items[1]->find(3);
     // This child record IS related to the current parent
     $collection = new Collection($items);
     $relation->setDataFromCollection($collection);
     $data = ReflectionHelper::getValue($relation, 'data');
     // I should have only one record, since the other one is not related to the current parent model
     $this->assertCount(1, $data);
 }
Exemple #17
0
 /**
  * @group               TreeModelScopeImmediateDescendants
  * @group               TreeModel
  * @covers              FOF30\Model\TreeModel::scopeImmediateDescendants
  * @dataProvider        TreeModelDataprovider::getTestScopeImmediateDescendants
  */
 public function testScopeImmediateDescendants($test, $check)
 {
     $config = array('autoChecks' => false, 'idFieldName' => 'foftest_nestedset_id', 'tableName' => '#__foftest_nestedsets');
     $table = new TreeModelStub(static::$container, $config);
     $table->findOrFail($test['loadid']);
     ReflectionHelper::invoke($table, 'scopeImmediateDescendants');
     // Let's get the built where clause and "normalize" it
     $reflection = ReflectionHelper::getValue($table, 'whereClauses');
     $where = array_pop($reflection);
     preg_match_all('#IN\\s?\\((.*?)\\)#', $where, $matches);
     $where = explode(',', str_replace("'", '', $matches[1][0]));
     $where = array_map('trim', $where);
     $this->assertEquals($check['result'], $where, 'TreeModel::scopeImmediateDescendants applied the wrong where - Case: ' . $check['case']);
 }
Exemple #18
0
 /**
  * @covers      FOF30\Factory\Magic\BaseFactory::__construct
  */
 public function test__construct()
 {
     $container = static::$container;
     $factory = $this->getMockForAbstractClass('FOF30\\Factory\\Magic\\BaseFactory', array($container));
     $this->assertSame($container, ReflectionHelper::getValue($factory, 'container'));
 }
Exemple #19
0
 /**
  * @covers FOF30\Event\Dispatcher::detach
  */
 public function testDetach()
 {
     ReflectionHelper::setValue($this->object, 'observers', array());
     ReflectionHelper::setValue($this->object, 'events', array());
     $observer1 = new FirstObserver($this->object);
     $observer2 = new SecondObserver($this->object);
     $observers = ReflectionHelper::getValue($this->object, 'observers');
     $this->assertCount(2, $observers);
     // Detaching an observer
     $this->object->detach($observer1);
     $observers = ReflectionHelper::getValue($this->object, 'observers');
     $this->assertCount(1, $observers);
     // Detaching the same observer
     $this->object->detach($observer1);
     $observers = ReflectionHelper::getValue($this->object, 'observers');
     $this->assertCount(1, $observers);
     // Detaching another observer
     $this->object->detach($observer2);
     $observers = ReflectionHelper::getValue($this->object, 'observers');
     $this->assertCount(0, $observers);
 }
Exemple #20
0
 /**
  * @group           DataModel
  * @group           DataModelGetRelations
  * @covers          FOF30\Model\DataModel::getRelations
  */
 public function testGetRelations()
 {
     $config = array('idFieldName' => 'foftest_bare_id', 'tableName' => '#__foftest_bares');
     $model = new DataModelStub(static::$container, $config);
     $refl = ReflectionHelper::getValue($model, 'relationManager');
     $obj = $model->getRelations();
     $this->assertSame($refl, $obj, 'DataModel::getRelations failed to return the internal object');
 }
Exemple #21
0
 /**
  * @group           Controller
  * @group           ControllerSetRedirect
  * @covers          FOF30\Controller\Controller::setRedirect
  * @dataProvider    ControllerDataprovider::getTestSetRedirect
  */
 public function testSetRedirect($test, $check)
 {
     $msg = 'Controller::setRedirect %s - Case: ' . $check['case'];
     $controller = new ControllerStub(new TestContainer(array('componentName' => 'com_eastwood')));
     ReflectionHelper::setValue($controller, 'messageType', $test['mock']['type']);
     $result = $controller->setRedirect($test['url'], $test['msg'], $test['type']);
     $redirect = ReflectionHelper::getValue($controller, 'redirect');
     $message = ReflectionHelper::getValue($controller, 'message');
     $type = ReflectionHelper::getValue($controller, 'messageType');
     $this->assertInstanceOf('\\FOF30\\Controller\\Controller', $result, sprintf($msg, 'Should return an instance of itself'));
     $this->assertEquals($check['redirect'], $redirect, sprintf($msg, 'Did not set the redirect url correctly'));
     $this->assertEquals($check['message'], $message, sprintf($msg, 'Did not set the message correctly'));
     $this->assertEquals($check['type'], $type, sprintf($msg, 'Did not set the message type correctly'));
 }
Exemple #22
0
 /**
  * @group       Model
  * @group       ModelSetIgnoreRequest
  * @covers      FOF30\Model\Model::setIgnoreRequest
  */
 public function testSetIgnoreRequest()
 {
     $model = new ModelStub(static::$container);
     $result = $model->setIgnoreRequest(true);
     $ignore = ReflectionHelper::getValue($model, '_ignoreRequest');
     $this->assertInstanceOf('\\FOF30\\Model\\Model', $result, 'Model::setIgnoreRequest should return an instance of itself');
     $this->assertEquals(true, $ignore, 'Model::setIgnoreRequest failed to set the flag');
 }
Exemple #23
0
 /**
  * @group           DataControllerEdit
  * @covers          FOF30\Controller\DataController::edit
  * @dataProvider    DataControllerDataprovider::getTestEdit
  */
 public function testEdit($test, $check)
 {
     $msg = 'DataController::edit %s - Case: ' . $check['case'];
     $sessionMock = array();
     $container = new TestContainer(array('componentName' => 'com_fakeapp', 'input' => new Input(array('returnurl' => $test['mock']['returnurl'] ? base64_encode($test['mock']['returnurl']) : '')), 'session' => new ClosureHelper(array('set' => function ($self, $key, $value, $namespace) use(&$sessionMock) {
         $sessionMock[$namespace . '.' . $key] = $value;
     }, 'get' => function ($self, $key, $default, $namespace) use(&$sessionMock) {
         $key = $namespace . '.' . $key;
         if (isset($sessionMock[$key])) {
             return $sessionMock[$key];
         }
         return $default;
     }))));
     $container->session->set('dummycontrollers.savedata', $test['mock']['session'], 'com_fakeapp');
     $modelMethods = array('getId', 'lock', 'bind', 'setFormName', 'getForm', 'isLocked');
     $model = $this->getMock('\\FOF30\\Tests\\Stubs\\Model\\DataModelStub', $modelMethods, array(), '', false);
     $model->expects($this->any())->method('getId')->willReturn($test['mock']['getId']);
     $method = $model->expects($this->any())->method('lock');
     if ($test['mock']['lock'] === 'throw') {
         $method->willThrowException(new \Exception('Exception thrown while locking'));
     } else {
         $method->willReturn(null);
     }
     $model->expects($check['bind'] ? $this->once() : $this->never())->method('bind')->with($this->equalTo($check['bind']));
     $model->expects($this->any())->method('setFormName')->with($this->equalTo($check['formName']));
     $model->expects($this->any())->method('getForm')->willReturn($test['mock']['getForm']);
     $controller = $this->getMock('\\FOF30\\Tests\\Stubs\\Controller\\DataControllerStub', array('getModel', 'getIDsFromRequest', 'setRedirect', 'display'), array($container));
     $controller->expects($this->any())->method('getModel')->willReturn($model);
     $controller->expects($check['getFromReq'] ? $this->once() : $this->never())->method('getIDsFromRequest');
     $controller->expects($check['redirect'] ? $this->once() : $this->never())->method('setRedirect')->with($this->equalTo($check['url']), $this->equalTo($check['msg']), $this->equalTo('error'));
     $controller->expects($this->any())->method('display')->with($this->equalTo($check['display']));
     ReflectionHelper::setValue($controller, 'layout', $test['mock']['layout']);
     ReflectionHelper::setValue($controller, 'cacheableTasks', $test['mock']['cache']);
     $controller->edit();
     $layout = ReflectionHelper::getValue($controller, 'layout');
     $hasForm = ReflectionHelper::getValue($controller, 'hasForm');
     $sessionData = $container->session->get('dummycontrollers.savedata', null, 'com_fakeapp');
     $this->assertEquals($check['layout'], $layout, sprintf($msg, 'Failed to set the layout'));
     $this->assertEquals($check['hasForm'], $hasForm, sprintf($msg, 'Failed to set the hasForm flag'));
     $this->assertNull($sessionData, sprintf($msg, 'Failed to wipe session data'));
 }
Exemple #24
0
 /**
  * @group       RelationManager
  * @group       RelationManagerResetRelations
  * @covers      FOF30\Model\DataModel\RelationManager::resetRelations
  */
 public function testResetRelations()
 {
     $fakeRelation = new ClosureHelper(array('setDataFromCollection' => function () {
     }));
     $model = $this->buildModel();
     $relation = new RelationManager($model);
     ReflectionHelper::setValue($relation, 'relations', array('test' => $fakeRelation));
     $relation->resetRelations();
     $relations = ReflectionHelper::getValue($relation, 'relations');
     $this->assertEmpty($relations, 'RelationManager::resetRelations Failed to reset the whole relations');
 }
Exemple #25
0
 /**
  * @group           BasicFactory
  * @covers          FOF30\Factory\BasicFactory::setSaveScaffolding
  */
 public function testSetSaveScaffolding()
 {
     $factory = new BasicFactory(static::$container);
     $factory->setSaveScaffolding(true);
     $this->assertTrue(ReflectionHelper::getValue($factory, 'saveScaffolding'), 'BasicFactory::setSaveScaffolding Failed to set the save scaffolding flag');
 }
Exemple #26
0
 /**
  * @group           SwitchFactory
  * @covers          FOF30\Factory\SwitchFactory::__construct
  */
 public function test__construct()
 {
     $factory = new SwitchFactory(static::$container);
     $this->assertTrue(ReflectionHelper::getValue($factory, 'formLookupInOtherSide'));
 }
Exemple #27
0
 /**
  * @covers          FOF30\Toolbar\Toolbar::setRenderFrontendSubmenu
  */
 public function testSetRenderFrontendSubmenu()
 {
     $toolbar = new ToolbarStub(static::$container);
     $toolbar->setRenderFrontendSubmenu(true);
     $this->assertTrue(ReflectionHelper::getValue($toolbar, 'renderFrontendSubmenu'));
 }
Exemple #28
0
 public function testConstructor()
 {
     $dummy = new FirstObserver($this->dispatcher);
     $this->assertEquals($dummy, self::$attachArguments);
     $this->assertEquals($this->dispatcher, ReflectionHelper::getValue($dummy, 'subject'));
 }
Exemple #29
0
 /**
  * @covers          FOF30\View\View::alias
  */
 public function testAlias()
 {
     $view = new ViewStub(static::$container);
     $view->alias('viewTemplate', 'alias');
     $aliases = ReflectionHelper::getValue($view, 'viewTemplateAliases');
     $this->assertArrayHasKey('alias', $aliases, 'View::alias Failed to set the template alias');
     $this->assertEquals('viewTemplate', $aliases['alias'], 'View::alias Failed to set the template alias');
 }