public function test_truncate()
 {
     $containerMock = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerInterface')->disableOriginalConstructor()->getMock();
     $containerMock->expects($this->any())->method('getParameter')->with('kernel.charset')->will($this->returnValue('UTF-8'));
     BackendModel::setContainer($containerMock);
     $this->assertEquals(TemplateModifiers::truncate('foo bar baz qux', 3, false, true), 'foo');
     $this->assertEquals(TemplateModifiers::truncate('foo bar baz qux', 4, false, true), 'foo');
     $this->assertEquals(TemplateModifiers::truncate('foo bar baz qux', 8, false, true), 'foo bar');
     $this->assertEquals(TemplateModifiers::truncate('foo bar baz qux', 100, false, true), 'foo bar baz qux');
     // Hellip
     $this->assertEquals(TemplateModifiers::truncate('foo bar baz qux', 5, true, true), 'foo…');
     $this->assertEquals(TemplateModifiers::truncate('foo bar baz qux', 14, true, true), 'foo bar baz…');
     $this->assertEquals(TemplateModifiers::truncate('foo bar baz qux', 15, true, true), 'foo bar baz qux');
 }
Beispiel #2
0
 /**
  * @todo: - make sure the Container doesn't have to be injected
  *        - make sure the Model::setContainer isn't needed anymore
  */
 public function __construct(Container $container, $rootDir)
 {
     $this->container = $container;
     $this->rootDir = $rootDir;
     Model::setContainer($container);
 }
Beispiel #3
0
 /**
  * This is fairly dirty, but so is having static method classes for models.
  * Consider this a temporary solution until we have genuine models available.
  */
 public function passContainerToModels()
 {
     FrontendModel::setContainer($this->getKernel()->getContainer());
     BackendModel::setContainer($this->getKernel()->getContainer());
 }