From 862d4a5016b6e98cb415a5a6a4a6b6afeae202dc Mon Sep 17 00:00:00 2001 From: Jason Irish Date: Mon, 11 Apr 2016 20:34:58 -0500 Subject: [PATCH] quick psr-2 cleanup --- code/FlexSliderExtension.php | 53 ++++++++++---------- tests/FlexSliderTest.php | 37 +++++++------- tests/SlideImageTest.php | 94 +++++++++++++++++------------------- 3 files changed, 91 insertions(+), 93 deletions(-) diff --git a/code/FlexSliderExtension.php b/code/FlexSliderExtension.php index 82fab45..0e9f815 100644 --- a/code/FlexSliderExtension.php +++ b/code/FlexSliderExtension.php @@ -1,33 +1,34 @@ owner->Animate) ? 'true' : 'false'; - $loop = ($this->owner->Loop) ? 'true' : 'false'; - $sync = ($this->owner->ThumbnailNav==true) ? "sync: '#carousel'," : ""; - $before = (method_exists($this->owner->ClassName, 'flexSliderBeforeAction')) - ? $this->owner->flexSliderBeforeAction() - : "function(){}"; - $after = (method_exists($this->owner->ClassName, 'flexSliderAfterAction')) - ? $this->owner->flexSliderAfterAction() - : "function(){}"; - $speed = (method_exists($this->owner->ClassName, 'setFlexSliderSpeed')) - ? $this->owner->setFlexSliderSpeed() - : 7000; + // Flexslider options + $animate = ($this->owner->Animate) ? 'true' : 'false'; + $loop = ($this->owner->Loop) ? 'true' : 'false'; + $sync = ($this->owner->ThumbnailNav == true) ? "sync: '#carousel'," : ''; + $before = (method_exists($this->owner->ClassName, 'flexSliderBeforeAction')) + ? $this->owner->flexSliderBeforeAction() + : 'function(){}'; + $after = (method_exists($this->owner->ClassName, 'flexSliderAfterAction')) + ? $this->owner->flexSliderAfterAction() + : 'function(){}'; + $speed = (method_exists($this->owner->ClassName, 'setFlexSliderSpeed')) + ? $this->owner->setFlexSliderSpeed() + : 7000; // only call custom script if page has Slides and DataExtension if (Object::has_extension($this->owner->data()->ClassName, 'FlexSlider')) { - if($this->owner->data()->Slides()->exists()){ + if ($this->owner->data()->Slides()->exists()) { Requirements::customScript(" (function($) { $(document).ready(function(){ $('.flexslider').flexslider({ - slideshow: " . $animate . ", - animation: '" . $this->owner->Animation . "', - animationLoop: " . $loop . ", + slideshow: ".$animate.", + animation: '".$this->owner->Animation."', + animationLoop: ".$loop.", controlNav: true, directionNav: true, prevText: '', @@ -38,15 +39,13 @@ public function onAfterInit() { start: function(slider){ $('body').removeClass('loading'); }, - before: ".$before.", - after: ".$after.", - slideshowSpeed: " . $speed . " + before: ".$before.', + after: '.$after.', + slideshowSpeed: '.$speed.' }); }); - }(jQuery));"); + }(jQuery));'); } } - - } - + } } diff --git a/tests/FlexSliderTest.php b/tests/FlexSliderTest.php index b6199c9..fc949e8 100644 --- a/tests/FlexSliderTest.php +++ b/tests/FlexSliderTest.php @@ -1,24 +1,27 @@ session()->clear('loggedInAs'); - $this->session()->clear('logInWithPermission'); - } - - public function testFlexSlider(){} + public function logOut() + { + $this->session()->clear('loggedInAs'); + $this->session()->clear('logInWithPermission'); + } + public function testFlexSlider() + { + } } diff --git a/tests/SlideImageTest.php b/tests/SlideImageTest.php index 2907079..8655cca 100644 --- a/tests/SlideImageTest.php +++ b/tests/SlideImageTest.php @@ -1,68 +1,64 @@ logInWithPermission('Slide_CREATE'); + $slide = $this->objFromFixture('SlideImage', 'slide1'); - function testSlideImageCreation(){ + $this->assertTrue($slide->canCreate()); - $this->logInWithPermission('Slide_CREATE'); - $slide = $this->objFromFixture('SlideImage', 'slide1'); + $slideID = $slide->ID; - $this->assertTrue($slide->canCreate()); + $this->assertTrue($slideID > 0); - $slideID = $slide->ID; + $getSlide = SlideImage::get()->byID($slideID); + $this->assertTrue($getSlide->ID == $slideID); + } - $this->assertTrue($slideID > 0); + public function testSlideUpdate() + { + $this->logInWithPermission('ADMIN'); + $slide = $this->objFromFixture('SlideImage', 'slide1'); + $slideID = $slide->ID; - $getSlide = SlideImage::get()->byID($slideID); - $this->assertTrue($getSlide->ID == $slideID); + $image = $this->objFromFixture('Image', 'image1'); + $imageID = $image->ID; - } + $this->logOut(); - function testSlideUpdate(){ + $this->logInWithPermission('Slide_EDIT'); - $this->logInWithPermission('ADMIN'); - $slide = $this->objFromFixture('SlideImage', 'slide1'); - $slideID = $slide->ID; + $this->assertTrue($slide->canEdit()); + $slide = SlideImage::get()->byID($slideID); + $newTitle = 'Updated Name for Slide'; + $slide->Name = $newTitle; + $slide->ImageID = $imageID; + $slide->write(); - $image = $this->objFromFixture('Image', 'image1'); - $imageID = $image->ID; + $slide = SlideImage::get()->byiD($slideID); - $this->logOut(); + $this->assertTrue($slide->Name == $newTitle); + } - $this->logInWithPermission('Slide_EDIT'); - - $this->assertTrue($slide->canEdit()); - $slide = SlideImage::get()->byID($slideID); - $newTitle = "Updated Name for Slide"; - $slide->Name = $newTitle; - $slide->ImageID = $imageID; - $slide->write(); - - $slide = SlideImage::get()->byiD($slideID); - - $this->assertTrue($slide->Name == $newTitle); - - } - - function testSlideImageDeletion(){ - - $this->logInWithPermission('Slide_DELETE'); - $slide = $this->objFromFixture('SlideImage', 'slide2'); - $slideID = $slide->ID; - - $this->assertTrue($slide->canDelete()); - $slide->delete(); - - $slides = SlideImage::get()->column('ID'); - $this->assertFalse(in_array($slideID, $slides)); - - } + public function testSlideImageDeletion() + { + $this->logInWithPermission('Slide_DELETE'); + $slide = $this->objFromFixture('SlideImage', 'slide2'); + $slideID = $slide->ID; + $this->assertTrue($slide->canDelete()); + $slide->delete(); + $slides = SlideImage::get()->column('ID'); + $this->assertFalse(in_array($slideID, $slides)); + } }